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
166166 }
167167
168168 #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+}
170180 #else /* BITS_PER_LONG < 64 */
171181 # define ktime_divns(kt, div) (u64)((kt).tv64 / (div))
172182 #endif
include/linux/rtc.h+1−1
@@ -161,7 +161,7 @@ extern void devm_rtc_device_unregister(struct device *dev, · 160 unmodified lines
161161 extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm);
162162 extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm);
163163 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);
165165 int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm);
166166 extern int rtc_read_alarm(struct rtc_device *rtc,
167167 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
3333
3434 extern int __getnstimeofday64(struct timespec64 *tv);
3535 extern void getnstimeofday64(struct timespec64 *tv);
36+extern void getboottime64(struct timespec64 *ts);
3637
3738 #if BITS_PER_LONG == 64
3839 /**
@@ -72,6 +73,11 @@ static inline struct timespec get_monotonic_coarse(void) · 33 unmodified lines
7273 {
7374 return get_monotonic_coarse64();
7475 }
76+
77+static inline void getboottime(struct timespec *ts)
78+{
79+ return getboottime64(ts);
80+}
7581 #else
7682 /**
7783 * Deprecated. Use do_settimeofday64().
@@ -129,9 +135,15 @@ static inline struct timespec get_monotonic_coarse(void) · 51 unmodified lines
129135 {
130136 return timespec64_to_timespec(get_monotonic_coarse64());
131137 }
132−#endif
133138
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
135147
136148 #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts)
137149 #define ktime_get_real_ts64(ts) getnstimeofday64(ts)
@@ -217,6 +229,11 @@ static inline void get_monotonic_boottime(struct timespec *ts) · 79 unmodified lines
217229 *ts = ktime_to_timespec(ktime_get_boottime());
218230 }
219231
232+static inline void get_monotonic_boottime64(struct timespec64 *ts)
233+{
234+ *ts = ktime_to_timespec64(ktime_get_boottime());
235+}
236+
220237 static inline void timekeeping_clocktai(struct timespec *ts)
221238 {
222239 *ts = ktime_to_timespec(ktime_get_clocktai());