diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/ktime.h | 12 | ||||
| -rw-r--r-- | include/linux/rtc.h | 2 | ||||
| -rw-r--r-- | include/linux/timekeeping.h | 21 |
3 files changed, 31 insertions, 4 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h index 891ea92a68b0..5fc3d1083071 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h | |||
| @@ -166,7 +166,17 @@ static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2) | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | #if BITS_PER_LONG < 64 | 168 | #if BITS_PER_LONG < 64 |
| 169 | extern u64 ktime_divns(const ktime_t kt, s64 div); | 169 | extern u64 __ktime_divns(const ktime_t kt, s64 div); |
| 170 | static inline u64 ktime_divns(const ktime_t kt, s64 div) | ||
| 171 | { | ||
| 172 | if (__builtin_constant_p(div) && !(div >> 32)) { | ||
| 173 | u64 ns = kt.tv64; | ||
| 174 | do_div(ns, div); | ||
| 175 | return ns; | ||
| 176 | } else { | ||
| 177 | return __ktime_divns(kt, div); | ||
| 178 | } | ||
| 179 | } | ||
| 170 | #else /* BITS_PER_LONG < 64 */ | 180 | #else /* BITS_PER_LONG < 64 */ |
| 171 | # define ktime_divns(kt, div) (u64)((kt).tv64 / (div)) | 181 | # define ktime_divns(kt, div) (u64)((kt).tv64 / (div)) |
| 172 | #endif | 182 | #endif |
diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 6d6be09a2fe5..dcad7ee0d746 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h | |||
| @@ -161,7 +161,7 @@ extern void devm_rtc_device_unregister(struct device *dev, | |||
| 161 | extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); | 161 | extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); |
| 162 | extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); | 162 | extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); |
| 163 | extern int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs); | 163 | extern int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs); |
| 164 | extern int rtc_set_ntp_time(struct timespec now); | 164 | extern int rtc_set_ntp_time(struct timespec64 now); |
| 165 | int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm); | 165 | int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm); |
| 166 | extern int rtc_read_alarm(struct rtc_device *rtc, | 166 | extern int rtc_read_alarm(struct rtc_device *rtc, |
| 167 | struct rtc_wkalrm *alrm); | 167 | struct rtc_wkalrm *alrm); |
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 9b63d13ba82b..3eaae4754275 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) |
| @@ -217,6 +229,11 @@ static inline void get_monotonic_boottime(struct timespec *ts) | |||
| 217 | *ts = ktime_to_timespec(ktime_get_boottime()); | 229 | *ts = ktime_to_timespec(ktime_get_boottime()); |
| 218 | } | 230 | } |
| 219 | 231 | ||
| 232 | static inline void get_monotonic_boottime64(struct timespec64 *ts) | ||
| 233 | { | ||
| 234 | *ts = ktime_to_timespec64(ktime_get_boottime()); | ||
| 235 | } | ||
| 236 | |||
| 220 | static inline void timekeeping_clocktai(struct timespec *ts) | 237 | static inline void timekeeping_clocktai(struct timespec *ts) |
| 221 | { | 238 | { |
| 222 | *ts = ktime_to_timespec(ktime_get_clocktai()); | 239 | *ts = ktime_to_timespec(ktime_get_clocktai()); |
