diff options
| author | Arnd Bergmann <arnd@arndb.de> | 2018-04-27 09:40:16 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2018-05-19 07:57:33 -0400 |
| commit | 06aa376903b6e8c8741395a4702d78d47c7c27c6 (patch) | |
| tree | f314891509345522dc90fcb93c0e14369bc5b745 | |
| parent | b9ff604cff1135cc576cf952d394ed9401aa234b (diff) | |
timekeeping: Add more coarse clocktai/boottime interfaces
The set of APIs we provide has a few holes for coarse times, e.g. we
provide ktime_get_coarse_boottime() and ktime_get_boottime_ts64(),
but not the combination of the two.
This adds four new functions:
ktime_get_coarse_boottime_ts64()
ktime_get_boottime_seconds()
ktime_get_coarse_clocktai_ts64()
ktime_get_clocktai_seconds()
to fill in some of the missing pieces. I have missed only the
ktime_get_boottime_seconds() accessor in a few occasions in
the past, but it seems better to just provide all four together,
as there is very little cost to having them.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: y2038@lists.linaro.org
Cc: John Stultz <john.stultz@linaro.org>
Link: https://lkml.kernel.org/r/20180427134016.2525989-6-arnd@arndb.de
| -rw-r--r-- | include/linux/timekeeping.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 42f71f4b658a..86bc2026efce 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h | |||
| @@ -137,18 +137,40 @@ extern u64 ktime_get_boot_fast_ns(void); | |||
| 137 | extern u64 ktime_get_real_fast_ns(void); | 137 | extern u64 ktime_get_real_fast_ns(void); |
| 138 | 138 | ||
| 139 | /* | 139 | /* |
| 140 | * timespec64 interfaces utilizing the ktime based ones | 140 | * timespec64/time64_t interfaces utilizing the ktime based ones |
| 141 | * for API completeness, these could be implemented more efficiently | ||
| 142 | * if needed. | ||
| 141 | */ | 143 | */ |
| 142 | static inline void ktime_get_boottime_ts64(struct timespec64 *ts) | 144 | static inline void ktime_get_boottime_ts64(struct timespec64 *ts) |
| 143 | { | 145 | { |
| 144 | *ts = ktime_to_timespec64(ktime_get_boottime()); | 146 | *ts = ktime_to_timespec64(ktime_get_boottime()); |
| 145 | } | 147 | } |
| 146 | 148 | ||
| 149 | static inline void ktime_get_coarse_boottime_ts64(struct timespec64 *ts) | ||
| 150 | { | ||
| 151 | *ts = ktime_to_timespec64(ktime_get_coarse_boottime()); | ||
| 152 | } | ||
| 153 | |||
| 154 | static inline time64_t ktime_get_boottime_seconds(void) | ||
| 155 | { | ||
| 156 | return ktime_divns(ktime_get_coarse_boottime(), NSEC_PER_SEC); | ||
| 157 | } | ||
| 158 | |||
| 147 | static inline void ktime_get_clocktai_ts64(struct timespec64 *ts) | 159 | static inline void ktime_get_clocktai_ts64(struct timespec64 *ts) |
| 148 | { | 160 | { |
| 149 | *ts = ktime_to_timespec64(ktime_get_clocktai()); | 161 | *ts = ktime_to_timespec64(ktime_get_clocktai()); |
| 150 | } | 162 | } |
| 151 | 163 | ||
| 164 | static inline void ktime_get_coarse_clocktai_ts64(struct timespec64 *ts) | ||
| 165 | { | ||
| 166 | *ts = ktime_to_timespec64(ktime_get_coarse_clocktai()); | ||
| 167 | } | ||
| 168 | |||
| 169 | static inline time64_t ktime_get_clocktai_seconds(void) | ||
| 170 | { | ||
| 171 | return ktime_divns(ktime_get_coarse_clocktai(), NSEC_PER_SEC); | ||
| 172 | } | ||
| 173 | |||
| 152 | /* | 174 | /* |
| 153 | * RTC specific | 175 | * RTC specific |
| 154 | */ | 176 | */ |
