Skip to content

Commit

Permalink
timekeeping: Simplify getboottime()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Gleixner authored and John Stultz committed Jul 23, 2014
1 parent 48f18fd commit 02cba15
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 02cba15

Please sign in to comment.