diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2014-07-16 17:04:57 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2014-07-23 18:01:47 -0400 |
commit | 48f18fd6addc199f330d838d54fe7b0a0892adaa (patch) | |
tree | 21f3f32df6a8ee014b6df7cd1b2653977df6f046 | |
parent | 250fade8af2ac5dda8d5106ea06738b6f9e768a7 (diff) |
timekeeping: Use ktime_get_boottime() for get_monotonic_boottime()
get_monotonic_boottime() is not used in fast pathes, so the extra
timespec conversion is not problematic.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r-- | include/linux/timekeeping.h | 9 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 34 |
2 files changed, 8 insertions, 35 deletions
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 8ea3ca1b0ee5..7b8f20007871 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h | |||
@@ -27,7 +27,6 @@ struct timespec __current_kernel_time(void); | |||
27 | */ | 27 | */ |
28 | struct timespec get_monotonic_coarse(void); | 28 | struct timespec get_monotonic_coarse(void); |
29 | extern void getrawmonotonic(struct timespec *ts); | 29 | extern void getrawmonotonic(struct timespec *ts); |
30 | extern void get_monotonic_boottime(struct timespec *ts); | ||
31 | extern void ktime_get_ts64(struct timespec64 *ts); | 30 | extern void ktime_get_ts64(struct timespec64 *ts); |
32 | 31 | ||
33 | extern int __getnstimeofday64(struct timespec64 *tv); | 32 | extern int __getnstimeofday64(struct timespec64 *tv); |
@@ -160,6 +159,14 @@ static inline u64 ktime_get_boot_ns(void) | |||
160 | } | 159 | } |
161 | 160 | ||
162 | /* | 161 | /* |
162 | * Timespec interfaces utilizing the ktime based ones | ||
163 | */ | ||
164 | static inline void get_monotonic_boottime(struct timespec *ts) | ||
165 | { | ||
166 | *ts = ktime_to_timespec(ktime_get_boottime()); | ||
167 | } | ||
168 | |||
169 | /* | ||
163 | * RTC specific | 170 | * RTC specific |
164 | */ | 171 | */ |
165 | extern void timekeeping_inject_sleeptime(struct timespec *delta); | 172 | extern void timekeeping_inject_sleeptime(struct timespec *delta); |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index b35613508725..f63476fb0daf 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -1536,40 +1536,6 @@ void getboottime(struct timespec *ts) | |||
1536 | } | 1536 | } |
1537 | EXPORT_SYMBOL_GPL(getboottime); | 1537 | EXPORT_SYMBOL_GPL(getboottime); |
1538 | 1538 | ||
1539 | /** | ||
1540 | * get_monotonic_boottime - Returns monotonic time since boot | ||
1541 | * @ts: pointer to the timespec to be set | ||
1542 | * | ||
1543 | * Returns the monotonic time since boot in a timespec. | ||
1544 | * | ||
1545 | * This is similar to CLOCK_MONTONIC/ktime_get_ts, but also | ||
1546 | * includes the time spent in suspend. | ||
1547 | */ | ||
1548 | void get_monotonic_boottime(struct timespec *ts) | ||
1549 | { | ||
1550 | struct timekeeper *tk = &tk_core.timekeeper; | ||
1551 | struct timespec64 tomono, sleep, ret; | ||
1552 | s64 nsec; | ||
1553 | unsigned int seq; | ||
1554 | |||
1555 | WARN_ON(timekeeping_suspended); | ||
1556 | |||
1557 | do { | ||
1558 | seq = read_seqcount_begin(&tk_core.seq); | ||
1559 | ret.tv_sec = tk->xtime_sec; | ||
1560 | nsec = timekeeping_get_ns(tk); | ||
1561 | tomono = tk->wall_to_monotonic; | ||
1562 | sleep = tk->total_sleep_time; | ||
1563 | |||
1564 | } while (read_seqcount_retry(&tk_core.seq, seq)); | ||
1565 | |||
1566 | ret.tv_sec += tomono.tv_sec + sleep.tv_sec; | ||
1567 | ret.tv_nsec = 0; | ||
1568 | timespec64_add_ns(&ret, nsec + tomono.tv_nsec + sleep.tv_nsec); | ||
1569 | *ts = timespec64_to_timespec(ret); | ||
1570 | } | ||
1571 | EXPORT_SYMBOL_GPL(get_monotonic_boottime); | ||
1572 | |||
1573 | unsigned long get_seconds(void) | 1539 | unsigned long get_seconds(void) |
1574 | { | 1540 | { |
1575 | struct timekeeper *tk = &tk_core.timekeeper; | 1541 | struct timekeeper *tk = &tk_core.timekeeper; |