diff options
author | John Stultz <john.stultz@linaro.org> | 2014-12-08 15:00:09 -0500 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2015-01-23 20:21:54 -0500 |
commit | d08c0cdd26d48751c15aa2b4479a410594fee9ac (patch) | |
tree | 8cba7b361ac9e8cdc99d2b167ba5317c679a8e74 | |
parent | 8b618628b2bf83512fc8df5e8672619d65adfdfb (diff) |
time: Expose getboottime64 for in-kernel uses
Adds a timespec64 based getboottime64() implementation
that can be used as we convert internal users of
getboottime away from using timespecs.
Cc: pang.xunlei <pang.xunlei@linaro.org>
Cc: Arnd Bergmann <arnd.bergmann@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r-- | include/linux/timekeeping.h | 16 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 12 |
2 files changed, 20 insertions, 8 deletions
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 9b63d13ba82b..91480137aa39 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h | |||
@@ -33,6 +33,7 @@ extern time64_t ktime_get_real_seconds(void); | |||
33 | 33 | ||
34 | extern int __getnstimeofday64(struct timespec64 *tv); | 34 | extern int __getnstimeofday64(struct timespec64 *tv); |
35 | extern void getnstimeofday64(struct timespec64 *tv); | 35 | extern void getnstimeofday64(struct timespec64 *tv); |
36 | extern void getboottime64(struct timespec64 *ts); | ||
36 | 37 | ||
37 | #if BITS_PER_LONG == 64 | 38 | #if BITS_PER_LONG == 64 |
38 | /** | 39 | /** |
@@ -72,6 +73,11 @@ static inline struct timespec get_monotonic_coarse(void) | |||
72 | { | 73 | { |
73 | return get_monotonic_coarse64(); | 74 | return get_monotonic_coarse64(); |
74 | } | 75 | } |
76 | |||
77 | static inline void getboottime(struct timespec *ts) | ||
78 | { | ||
79 | return getboottime64(ts); | ||
80 | } | ||
75 | #else | 81 | #else |
76 | /** | 82 | /** |
77 | * Deprecated. Use do_settimeofday64(). | 83 | * Deprecated. Use do_settimeofday64(). |
@@ -129,9 +135,15 @@ static inline struct timespec get_monotonic_coarse(void) | |||
129 | { | 135 | { |
130 | return timespec64_to_timespec(get_monotonic_coarse64()); | 136 | return timespec64_to_timespec(get_monotonic_coarse64()); |
131 | } | 137 | } |
132 | #endif | ||
133 | 138 | ||
134 | extern void getboottime(struct timespec *ts); | 139 | static inline void getboottime(struct timespec *ts) |
140 | { | ||
141 | struct timespec64 ts64; | ||
142 | |||
143 | getboottime64(&ts64); | ||
144 | *ts = timespec64_to_timespec(ts64); | ||
145 | } | ||
146 | #endif | ||
135 | 147 | ||
136 | #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) | 148 | #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) |
137 | #define ktime_get_real_ts64(ts) getnstimeofday64(ts) | 149 | #define ktime_get_real_ts64(ts) getnstimeofday64(ts) |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 6a931852082f..b124af259800 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -1659,24 +1659,24 @@ out: | |||
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | /** | 1661 | /** |
1662 | * getboottime - Return the real time of system boot. | 1662 | * getboottime64 - Return the real time of system boot. |
1663 | * @ts: pointer to the timespec to be set | 1663 | * @ts: pointer to the timespec64 to be set |
1664 | * | 1664 | * |
1665 | * Returns the wall-time of boot in a timespec. | 1665 | * Returns the wall-time of boot in a timespec64. |
1666 | * | 1666 | * |
1667 | * This is based on the wall_to_monotonic offset and the total suspend | 1667 | * This is based on the wall_to_monotonic offset and the total suspend |
1668 | * time. Calls to settimeofday will affect the value returned (which | 1668 | * time. Calls to settimeofday will affect the value returned (which |
1669 | * basically means that however wrong your real time clock is at boot time, | 1669 | * basically means that however wrong your real time clock is at boot time, |
1670 | * you get the right time here). | 1670 | * you get the right time here). |
1671 | */ | 1671 | */ |
1672 | void getboottime(struct timespec *ts) | 1672 | void getboottime64(struct timespec64 *ts) |
1673 | { | 1673 | { |
1674 | struct timekeeper *tk = &tk_core.timekeeper; | 1674 | struct timekeeper *tk = &tk_core.timekeeper; |
1675 | ktime_t t = ktime_sub(tk->offs_real, tk->offs_boot); | 1675 | ktime_t t = ktime_sub(tk->offs_real, tk->offs_boot); |
1676 | 1676 | ||
1677 | *ts = ktime_to_timespec(t); | 1677 | *ts = ktime_to_timespec64(t); |
1678 | } | 1678 | } |
1679 | EXPORT_SYMBOL_GPL(getboottime); | 1679 | EXPORT_SYMBOL_GPL(getboottime64); |
1680 | 1680 | ||
1681 | unsigned long get_seconds(void) | 1681 | unsigned long get_seconds(void) |
1682 | { | 1682 | { |