Pull time updates from John Stultz for 3.20: * ktime division optimization * Expose a few more y2038-safe timekeeping interfaces * RTC core changes to address y2038
Showing the changes to include (3 of 10 files). Show all
Unified · Split
| @@ -166,7 +166,17 @@ static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2) · 165 unmodified lines | ||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 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 | 180 | #else /* BITS_PER_LONG < 64 */ |
| 171 | 181 | # define ktime_divns(kt, div) (u64)((kt).tv64 / (div)) |
| 172 | 182 | #endif |
| @@ -161,7 +161,7 @@ extern void devm_rtc_device_unregister(struct device *dev, · 160 unmodified lines | ||
| 161 | 161 | extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); |
| 162 | 162 | extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); |
| 163 | 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 | 165 | int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm); |
| 166 | 166 | extern int rtc_read_alarm(struct rtc_device *rtc, |
| 167 | 167 | struct rtc_wkalrm *alrm); |
| @@ -33,6 +33,7 @@ extern time64_t ktime_get_real_seconds(void); · 32 unmodified lines | ||
| 33 | 33 | |
| 34 | 34 | extern int __getnstimeofday64(struct timespec64 *tv); |
| 35 | 35 | extern void getnstimeofday64(struct timespec64 *tv); |
| 36 | +extern void getboottime64(struct timespec64 *ts); | |
| 36 | 37 | |
| 37 | 38 | #if BITS_PER_LONG == 64 |
| 38 | 39 | /** |
| @@ -72,6 +73,11 @@ static inline struct timespec get_monotonic_coarse(void) · 33 unmodified lines | ||
| 72 | 73 | { |
| 73 | 74 | return get_monotonic_coarse64(); |
| 74 | 75 | } |
| 76 | + | |
| 77 | +static inline void getboottime(struct timespec *ts) | |
| 78 | +{ | |
| 79 | + return getboottime64(ts); | |
| 80 | +} | |
| 75 | 81 | #else |
| 76 | 82 | /** |
| 77 | 83 | * Deprecated. Use do_settimeofday64(). |
| @@ -129,9 +135,15 @@ static inline struct timespec get_monotonic_coarse(void) · 51 unmodified lines | ||
| 129 | 135 | { |
| 130 | 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 | 148 | #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) |
| 137 | 149 | #define ktime_get_real_ts64(ts) getnstimeofday64(ts) |
| @@ -217,6 +229,11 @@ static inline void get_monotonic_boottime(struct timespec *ts) · 79 unmodified lines | ||
| 217 | 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 | 237 | static inline void timekeeping_clocktai(struct timespec *ts) |
| 221 | 238 | { |
| 222 | 239 | *ts = ktime_to_timespec(ktime_get_clocktai()); |