History

Merge tag 'fortglx-3.20-time' of https://git.linaro.org/people/john.stultz/linux into timers/core

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

Thomas Gleixner committed 11 years ago

Commit fe31fca2 parents 9bc7491 9a4a44510 files · +63 −46Browse files

Showing the changes to include (3 of 10 files). Show all

Unified · Split

3 files
  1. include/linux/ktime.h +11 −1
  2. include/linux/rtc.h +1 −1
  3. include/linux/timekeeping.h +19 −2
include/linux/ktime.h+11−1
@@ -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#if BITS_PER_LONG < 64168#if BITS_PER_LONG < 64
169extern u64 ktime_divns(const ktime_t kt, s64 div);169extern u64 __ktime_divns(const ktime_t kt, s64 div);
170static 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#endif182#endif
include/linux/rtc.h+1−1
@@ -161,7 +161,7 @@ extern void devm_rtc_device_unregister(struct device *dev, · 160 unmodified lines
161extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm);161extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm);
162extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm);162extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm);
163extern int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs);163extern int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs);
164extern int rtc_set_ntp_time(struct timespec now);164extern int rtc_set_ntp_time(struct timespec64 now);
165int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm);165int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm);
166extern int rtc_read_alarm(struct rtc_device *rtc,166extern int rtc_read_alarm(struct rtc_device *rtc,
167 struct rtc_wkalrm *alrm);167 struct rtc_wkalrm *alrm);
include/linux/timekeeping.h+19−2
@@ -33,6 +33,7 @@ extern time64_t ktime_get_real_seconds(void); · 32 unmodified lines
33 33
34extern int __getnstimeofday64(struct timespec64 *tv);34extern int __getnstimeofday64(struct timespec64 *tv);
35extern void getnstimeofday64(struct timespec64 *tv);35extern void getnstimeofday64(struct timespec64 *tv);
36extern void getboottime64(struct timespec64 *ts);
36 37
37#if BITS_PER_LONG == 6438#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 return get_monotonic_coarse64();74 return get_monotonic_coarse64();
74}75}
76
77static inline void getboottime(struct timespec *ts)
78{
79 return getboottime64(ts);
80}
75#else81#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) · 51 unmodified lines
129{135{
130 return timespec64_to_timespec(get_monotonic_coarse64());136 return timespec64_to_timespec(get_monotonic_coarse64());
131}137}
132#endif
133 138
134extern void getboottime(struct timespec *ts);139static 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) · 79 unmodified lines
217 *ts = ktime_to_timespec(ktime_get_boottime());229 *ts = ktime_to_timespec(ktime_get_boottime());
218}230}
219 231
232static inline void get_monotonic_boottime64(struct timespec64 *ts)
233{
234 *ts = ktime_to_timespec64(ktime_get_boottime());
235}
236
220static inline void timekeeping_clocktai(struct timespec *ts)237static 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());