diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-09 19:33:07 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-09 19:33:07 -0500 |
commit | 0ba97bc4b4b054b71cd348dab838a7545a27b893 (patch) | |
tree | 6ceac2634bbf46410ddc015c98689c150e1e8571 /drivers/rtc | |
parent | 5b9b28a63f2e47dac5ff3a2503bfe3ade8796aa0 (diff) | |
parent | 4ebbda5251374d532ba8939de4241d769d1420b6 (diff) |
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer updates from Ingo Molnar:
"The main changes in this cycle were:
- rework hrtimer expiry calculation in hrtimer_interrupt(): the
previous code had a subtle bug where expiry caching would miss an
expiry, resulting in occasional bogus (late) expiry of hrtimers.
- continuing Y2038 fixes
- ktime division optimization
- misc smaller fixes and cleanups"
* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
hrtimer: Make __hrtimer_get_next_event() static
rtc: Convert rtc_set_ntp_time() to use timespec64
rtc: Remove redundant rtc_valid_tm() from rtc_hctosys()
rtc: Modify rtc_hctosys() to address y2038 issues
rtc: Update rtc-dev to use y2038-safe time interfaces
rtc: Update interface.c to use y2038-safe time interfaces
time: Expose get_monotonic_boottime64 for in-kernel use
time: Expose getboottime64 for in-kernel uses
ktime: Optimize ktime_divns for constant divisors
hrtimer: Prevent stale expiry time in hrtimer_interrupt()
ktime.h: Introduce ktime_ms_delta
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/hctosys.c | 18 | ||||
-rw-r--r-- | drivers/rtc/interface.c | 22 | ||||
-rw-r--r-- | drivers/rtc/rtc-dev.c | 8 | ||||
-rw-r--r-- | drivers/rtc/systohc.c | 6 |
4 files changed, 22 insertions, 32 deletions
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c index 4aa60d74004e..6c719f23520a 100644 --- a/drivers/rtc/hctosys.c +++ b/drivers/rtc/hctosys.c | |||
@@ -26,7 +26,7 @@ static int __init rtc_hctosys(void) | |||
26 | { | 26 | { |
27 | int err = -ENODEV; | 27 | int err = -ENODEV; |
28 | struct rtc_time tm; | 28 | struct rtc_time tm; |
29 | struct timespec tv = { | 29 | struct timespec64 tv64 = { |
30 | .tv_nsec = NSEC_PER_SEC >> 1, | 30 | .tv_nsec = NSEC_PER_SEC >> 1, |
31 | }; | 31 | }; |
32 | struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); | 32 | struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); |
@@ -45,25 +45,17 @@ static int __init rtc_hctosys(void) | |||
45 | 45 | ||
46 | } | 46 | } |
47 | 47 | ||
48 | err = rtc_valid_tm(&tm); | 48 | tv64.tv_sec = rtc_tm_to_time64(&tm); |
49 | if (err) { | ||
50 | dev_err(rtc->dev.parent, | ||
51 | "hctosys: invalid date/time\n"); | ||
52 | goto err_invalid; | ||
53 | } | ||
54 | |||
55 | rtc_tm_to_time(&tm, &tv.tv_sec); | ||
56 | 49 | ||
57 | err = do_settimeofday(&tv); | 50 | err = do_settimeofday64(&tv64); |
58 | 51 | ||
59 | dev_info(rtc->dev.parent, | 52 | dev_info(rtc->dev.parent, |
60 | "setting system clock to " | 53 | "setting system clock to " |
61 | "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n", | 54 | "%d-%02d-%02d %02d:%02d:%02d UTC (%lld)\n", |
62 | tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, | 55 | tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, |
63 | tm.tm_hour, tm.tm_min, tm.tm_sec, | 56 | tm.tm_hour, tm.tm_min, tm.tm_sec, |
64 | (unsigned int) tv.tv_sec); | 57 | (long long) tv64.tv_sec); |
65 | 58 | ||
66 | err_invalid: | ||
67 | err_read: | 59 | err_read: |
68 | rtc_class_close(rtc); | 60 | rtc_class_close(rtc); |
69 | 61 | ||
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 45bfc28ee3aa..37215cf983e9 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -73,10 +73,8 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) | |||
73 | else if (rtc->ops->set_time) | 73 | else if (rtc->ops->set_time) |
74 | err = rtc->ops->set_time(rtc->dev.parent, tm); | 74 | err = rtc->ops->set_time(rtc->dev.parent, tm); |
75 | else if (rtc->ops->set_mmss) { | 75 | else if (rtc->ops->set_mmss) { |
76 | unsigned long secs; | 76 | time64_t secs64 = rtc_tm_to_time64(tm); |
77 | err = rtc_tm_to_time(tm, &secs); | 77 | err = rtc->ops->set_mmss(rtc->dev.parent, secs64); |
78 | if (err == 0) | ||
79 | err = rtc->ops->set_mmss(rtc->dev.parent, secs); | ||
80 | } else | 78 | } else |
81 | err = -EINVAL; | 79 | err = -EINVAL; |
82 | 80 | ||
@@ -105,7 +103,7 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) | |||
105 | 103 | ||
106 | err = rtc->ops->read_time(rtc->dev.parent, &old); | 104 | err = rtc->ops->read_time(rtc->dev.parent, &old); |
107 | if (err == 0) { | 105 | if (err == 0) { |
108 | rtc_time_to_tm(secs, &new); | 106 | rtc_time64_to_tm(secs, &new); |
109 | 107 | ||
110 | /* | 108 | /* |
111 | * avoid writing when we're going to change the day of | 109 | * avoid writing when we're going to change the day of |
@@ -157,7 +155,7 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
157 | int err; | 155 | int err; |
158 | struct rtc_time before, now; | 156 | struct rtc_time before, now; |
159 | int first_time = 1; | 157 | int first_time = 1; |
160 | unsigned long t_now, t_alm; | 158 | time64_t t_now, t_alm; |
161 | enum { none, day, month, year } missing = none; | 159 | enum { none, day, month, year } missing = none; |
162 | unsigned days; | 160 | unsigned days; |
163 | 161 | ||
@@ -258,8 +256,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
258 | } | 256 | } |
259 | 257 | ||
260 | /* with luck, no rollover is needed */ | 258 | /* with luck, no rollover is needed */ |
261 | rtc_tm_to_time(&now, &t_now); | 259 | t_now = rtc_tm_to_time64(&now); |
262 | rtc_tm_to_time(&alarm->time, &t_alm); | 260 | t_alm = rtc_tm_to_time64(&alarm->time); |
263 | if (t_now < t_alm) | 261 | if (t_now < t_alm) |
264 | goto done; | 262 | goto done; |
265 | 263 | ||
@@ -273,7 +271,7 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
273 | case day: | 271 | case day: |
274 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day"); | 272 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day"); |
275 | t_alm += 24 * 60 * 60; | 273 | t_alm += 24 * 60 * 60; |
276 | rtc_time_to_tm(t_alm, &alarm->time); | 274 | rtc_time64_to_tm(t_alm, &alarm->time); |
277 | break; | 275 | break; |
278 | 276 | ||
279 | /* Month rollover ... if it's the 31th, an alarm on the 3rd will | 277 | /* Month rollover ... if it's the 31th, an alarm on the 3rd will |
@@ -346,19 +344,19 @@ EXPORT_SYMBOL_GPL(rtc_read_alarm); | |||
346 | static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 344 | static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
347 | { | 345 | { |
348 | struct rtc_time tm; | 346 | struct rtc_time tm; |
349 | long now, scheduled; | 347 | time64_t now, scheduled; |
350 | int err; | 348 | int err; |
351 | 349 | ||
352 | err = rtc_valid_tm(&alarm->time); | 350 | err = rtc_valid_tm(&alarm->time); |
353 | if (err) | 351 | if (err) |
354 | return err; | 352 | return err; |
355 | rtc_tm_to_time(&alarm->time, &scheduled); | 353 | scheduled = rtc_tm_to_time64(&alarm->time); |
356 | 354 | ||
357 | /* Make sure we're not setting alarms in the past */ | 355 | /* Make sure we're not setting alarms in the past */ |
358 | err = __rtc_read_time(rtc, &tm); | 356 | err = __rtc_read_time(rtc, &tm); |
359 | if (err) | 357 | if (err) |
360 | return err; | 358 | return err; |
361 | rtc_tm_to_time(&tm, &now); | 359 | now = rtc_tm_to_time64(&tm); |
362 | if (scheduled <= now) | 360 | if (scheduled <= now) |
363 | return -ETIME; | 361 | return -ETIME; |
364 | /* | 362 | /* |
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index d04939369251..799c34bcb26f 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -304,12 +304,12 @@ static long rtc_dev_ioctl(struct file *file, | |||
304 | * Not supported here. | 304 | * Not supported here. |
305 | */ | 305 | */ |
306 | { | 306 | { |
307 | unsigned long now, then; | 307 | time64_t now, then; |
308 | 308 | ||
309 | err = rtc_read_time(rtc, &tm); | 309 | err = rtc_read_time(rtc, &tm); |
310 | if (err < 0) | 310 | if (err < 0) |
311 | return err; | 311 | return err; |
312 | rtc_tm_to_time(&tm, &now); | 312 | now = rtc_tm_to_time64(&tm); |
313 | 313 | ||
314 | alarm.time.tm_mday = tm.tm_mday; | 314 | alarm.time.tm_mday = tm.tm_mday; |
315 | alarm.time.tm_mon = tm.tm_mon; | 315 | alarm.time.tm_mon = tm.tm_mon; |
@@ -317,11 +317,11 @@ static long rtc_dev_ioctl(struct file *file, | |||
317 | err = rtc_valid_tm(&alarm.time); | 317 | err = rtc_valid_tm(&alarm.time); |
318 | if (err < 0) | 318 | if (err < 0) |
319 | return err; | 319 | return err; |
320 | rtc_tm_to_time(&alarm.time, &then); | 320 | then = rtc_tm_to_time64(&alarm.time); |
321 | 321 | ||
322 | /* alarm may need to wrap into tomorrow */ | 322 | /* alarm may need to wrap into tomorrow */ |
323 | if (then < now) { | 323 | if (then < now) { |
324 | rtc_time_to_tm(now + 24 * 60 * 60, &tm); | 324 | rtc_time64_to_tm(now + 24 * 60 * 60, &tm); |
325 | alarm.time.tm_mday = tm.tm_mday; | 325 | alarm.time.tm_mday = tm.tm_mday; |
326 | alarm.time.tm_mon = tm.tm_mon; | 326 | alarm.time.tm_mon = tm.tm_mon; |
327 | alarm.time.tm_year = tm.tm_year; | 327 | alarm.time.tm_year = tm.tm_year; |
diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c index bf3e242ccc5c..eb71872d0361 100644 --- a/drivers/rtc/systohc.c +++ b/drivers/rtc/systohc.c | |||
@@ -20,16 +20,16 @@ | |||
20 | * | 20 | * |
21 | * If temporary failure is indicated the caller should try again 'soon' | 21 | * If temporary failure is indicated the caller should try again 'soon' |
22 | */ | 22 | */ |
23 | int rtc_set_ntp_time(struct timespec now) | 23 | int rtc_set_ntp_time(struct timespec64 now) |
24 | { | 24 | { |
25 | struct rtc_device *rtc; | 25 | struct rtc_device *rtc; |
26 | struct rtc_time tm; | 26 | struct rtc_time tm; |
27 | int err = -ENODEV; | 27 | int err = -ENODEV; |
28 | 28 | ||
29 | if (now.tv_nsec < (NSEC_PER_SEC >> 1)) | 29 | if (now.tv_nsec < (NSEC_PER_SEC >> 1)) |
30 | rtc_time_to_tm(now.tv_sec, &tm); | 30 | rtc_time64_to_tm(now.tv_sec, &tm); |
31 | else | 31 | else |
32 | rtc_time_to_tm(now.tv_sec + 1, &tm); | 32 | rtc_time64_to_tm(now.tv_sec + 1, &tm); |
33 | 33 | ||
34 | rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); | 34 | rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); |
35 | if (rtc) { | 35 | if (rtc) { |