]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - kernel/time/timekeeping.c
xen: include xen/xen.h for definition of xen_initial_domain()
[karo-tx-linux.git] / kernel / time / timekeeping.c
index e14c839e9faa7ab212d805ea41ffaa16667abc23..49010d822f725b47726742fa7e1b45aad076ef90 100644 (file)
@@ -690,6 +690,7 @@ static void timekeeping_adjust(s64 offset)
 static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
 {
        u64 nsecps = (u64)NSEC_PER_SEC << timekeeper.shift;
+       u64 raw_nsecs;
 
        /* If the offset is smaller then a shifted interval, do nothing */
        if (offset < timekeeper.cycle_interval<<shift)
@@ -706,12 +707,15 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
                second_overflow();
        }
 
-       /* Accumulate into raw time */
-       raw_time.tv_nsec += timekeeper.raw_interval << shift;;
-       while (raw_time.tv_nsec >= NSEC_PER_SEC) {
-               raw_time.tv_nsec -= NSEC_PER_SEC;
-               raw_time.tv_sec++;
+       /* Accumulate raw time */
+       raw_nsecs = timekeeper.raw_interval << shift;
+       raw_nsecs += raw_time.tv_nsec;
+       if (raw_nsecs >= NSEC_PER_SEC) {
+               u64 raw_secs = raw_nsecs;
+               raw_nsecs = do_div(raw_secs, NSEC_PER_SEC);
+               raw_time.tv_sec += raw_secs;
        }
+       raw_time.tv_nsec = raw_nsecs;
 
        /* Accumulate error between NTP and clock interval */
        timekeeper.ntp_error += tick_length << shift;