]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
timekeeping: Simplify getboottime()
authorThomas Gleixner <tglx@linutronix.de>
Wed, 16 Jul 2014 21:04:58 +0000 (21:04 +0000)
committerJohn Stultz <john.stultz@linaro.org>
Wed, 23 Jul 2014 22:01:47 +0000 (15:01 -0700)
Subtracting plain nsec values and converting to timespec is simpler
than the whole timespec math. Not really fastpath code, so the
division is not an issue.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
kernel/time/timekeeping.c

index f63476fb0daf8b38374bfad503621b507605affc..3edc0c1d6fe8bdd4692234b30b74b773e5447ccd 100644 (file)
@@ -1525,14 +1525,9 @@ void update_wall_time(void)
 void getboottime(struct timespec *ts)
 {
        struct timekeeper *tk = &tk_core.timekeeper;
-       struct timespec boottime = {
-               .tv_sec = tk->wall_to_monotonic.tv_sec +
-                               tk->total_sleep_time.tv_sec,
-               .tv_nsec = tk->wall_to_monotonic.tv_nsec +
-                               tk->total_sleep_time.tv_nsec
-       };
-
-       set_normalized_timespec(ts, -boottime.tv_sec, -boottime.tv_nsec);
+       ktime_t t = ktime_sub(tk->offs_real, tk->offs_boot);
+
+       *ts = ktime_to_timespec(t);
 }
 EXPORT_SYMBOL_GPL(getboottime);