]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - kernel/time.c
[PATCH] Memory Add Fixes for ppc64
[karo-tx-linux.git] / kernel / time.c
index 40c2410ac99ab15b80a7e3b6c5ed8477460de7a7..245d595a13cb9f566f67c2ac6ab6dfb8c0af1143 100644 (file)
@@ -338,30 +338,20 @@ int do_adjtimex(struct timex *txc)
                        if (mtemp >= MINSEC) {
                            ltemp = (time_offset / mtemp) << (SHIFT_USEC -
                                                              SHIFT_UPDATE);
-                           if (ltemp < 0)
-                               time_freq -= -ltemp >> SHIFT_KH;
-                           else
-                               time_freq += ltemp >> SHIFT_KH;
+                           time_freq += shift_right(ltemp, SHIFT_KH);
                        } else /* calibration interval too short (p. 12) */
                                result = TIME_ERROR;
                    } else {    /* PLL mode */
                        if (mtemp < MAXSEC) {
                            ltemp *= mtemp;
-                           if (ltemp < 0)
-                               time_freq -= -ltemp >> (time_constant +
-                                                       time_constant +
-                                                       SHIFT_KF - SHIFT_USEC);
-                           else
-                               time_freq += ltemp >> (time_constant +
+                           time_freq += shift_right(ltemp,(time_constant +
                                                       time_constant +
-                                                      SHIFT_KF - SHIFT_USEC);
+                                                      SHIFT_KF - SHIFT_USEC));
                        } else /* calibration interval too long (p. 12) */
                                result = TIME_ERROR;
                    }
-                   if (time_freq > time_tolerance)
-                       time_freq = time_tolerance;
-                   else if (time_freq < -time_tolerance)
-                       time_freq = -time_tolerance;
+                   time_freq = min(time_freq, time_tolerance);
+                   time_freq = max(time_freq, -time_tolerance);
                } /* STA_PLL || STA_PPSTIME */
            } /* txc->modes & ADJ_OFFSET */
            if (txc->modes & ADJ_TICK) {
@@ -384,10 +374,7 @@ leave:     if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0
        if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT)
            txc->offset    = save_adjust;
        else {
-           if (time_offset < 0)
-               txc->offset = -(-time_offset >> SHIFT_UPDATE);
-           else
-               txc->offset = time_offset >> SHIFT_UPDATE;
+           txc->offset = shift_right(time_offset, SHIFT_UPDATE);
        }
        txc->freq          = time_freq + pps_freq;
        txc->maxerror      = time_maxerror;
@@ -532,6 +519,7 @@ int do_settimeofday (struct timespec *tv)
        clock_was_set();
        return 0;
 }
+EXPORT_SYMBOL(do_settimeofday);
 
 void do_gettimeofday (struct timeval *tv)
 {