cpumask: avoid dereferencing struct cpumask
[safe/jmp/linux-2.6] / kernel / time / ntp.c
index 7447d57..4800f93 100644 (file)
@@ -71,7 +71,8 @@ static long                   time_reftime;
 
 long                           time_adjust;
 
-static long                    ntp_tick_adj;
+/* constant (boot-param configurable) NTP tick adjustment (upscaled)   */
+static s64                     ntp_tick_adj;
 
 /*
  * NTP methods:
@@ -89,7 +90,7 @@ static void ntp_update_frequency(void)
        second_length            = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ)
                                                << NTP_SCALE_SHIFT;
 
-       second_length           += (s64)ntp_tick_adj << NTP_SCALE_SHIFT;
+       second_length           += ntp_tick_adj;
        second_length           += time_freq;
 
        tick_nsec                = div_u64(second_length, HZ) >> NTP_SCALE_SHIFT;
@@ -193,8 +194,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
        case TIME_OK:
                break;
        case TIME_INS:
-               xtime.tv_sec--;
-               wall_to_monotonic.tv_sec++;
+               timekeeping_leap_insert(-1);
                time_state = TIME_OOP;
                printk(KERN_NOTICE
                        "Clock: inserting leap second 23:59:60 UTC\n");
@@ -202,9 +202,8 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
                res = HRTIMER_RESTART;
                break;
        case TIME_DEL:
-               xtime.tv_sec++;
+               timekeeping_leap_insert(1);
                time_tai--;
-               wall_to_monotonic.tv_sec--;
                time_state = TIME_WAIT;
                printk(KERN_NOTICE
                        "Clock: deleting leap second 23:59:59 UTC\n");
@@ -218,7 +217,6 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
                        time_state = TIME_OK;
                break;
        }
-       update_vsyscall(&xtime, clock);
 
        write_sequnlock(&xtime_lock);
 
@@ -235,7 +233,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
  */
 void second_overflow(void)
 {
-       s64 time_adj;
+       s64 delta;
 
        /* Bump the maxerror field */
        time_maxerror += MAXFREQ / NSEC_PER_USEC;
@@ -248,10 +246,11 @@ void second_overflow(void)
         * Compute the phase adjustment for the next second. The offset is
         * reduced by a fixed factor times the time constant.
         */
-       tick_length     = tick_length_base;
-       time_adj        = shift_right(time_offset, SHIFT_PLL + time_constant);
-       time_offset     -= time_adj;
-       tick_length     += time_adj;
+       tick_length      = tick_length_base;
+
+       delta            = shift_right(time_offset, SHIFT_PLL + time_constant);
+       time_offset     -= delta;
+       tick_length     += delta;
 
        if (!time_adjust)
                return;
@@ -363,8 +362,6 @@ static inline void process_adj_status(struct timex *txc, struct timespec *ts)
                time_state = TIME_OK;
                time_status = STA_UNSYNC;
        }
-       /* only set allowed bits */
-       time_status &= STA_RONLY;
 
        /*
         * If we turn on PLL adjustments then reset the
@@ -373,6 +370,8 @@ static inline void process_adj_status(struct timex *txc, struct timespec *ts)
        if (!(time_status & STA_PLL) && (txc->status & STA_PLL))
                time_reftime = xtime.tv_sec;
 
+       /* only set allowed bits */
+       time_status &= STA_RONLY;
        time_status |= txc->status & ~STA_RONLY;
 
        switch (time_state) {
@@ -540,6 +539,8 @@ int do_adjtimex(struct timex *txc)
 static int __init ntp_tick_adj_setup(char *str)
 {
        ntp_tick_adj = simple_strtol(str, NULL, 0);
+       ntp_tick_adj <<= NTP_SCALE_SHIFT;
+
        return 1;
 }