diff options
author | Xunlei Pang <pang.xunlei@linaro.org> | 2015-01-21 21:31:55 -0500 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2015-01-23 20:21:57 -0500 |
commit | 9a4a445e30f0b601ca2d9433274047cbf48ebf9e (patch) | |
tree | b02b62d1598b6a84332d527ec7e9ba996948d084 | |
parent | 966301a23ef8ff0a4c5f71b585dafbf334808574 (diff) |
rtc: Convert rtc_set_ntp_time() to use timespec64
rtc_set_ntp_time() uses timespec which is y2038-unsafe,
so modify to use timespec64 which is y2038-safe, then
replace rtc_time_to_tm() with rtc_time64_to_tm().
Also adjust all its call sites(only NTP uses it) accordingly.
Cc: pang.xunlei <pang.xunlei@linaro.org>
Cc: Arnd Bergmann <arnd.bergmann@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r-- | drivers/rtc/systohc.c | 6 | ||||
-rw-r--r-- | include/linux/rtc.h | 2 | ||||
-rw-r--r-- | kernel/time/ntp.c | 4 |
3 files changed, 6 insertions, 6 deletions
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) { |
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/kernel/time/ntp.c b/kernel/time/ntp.c index 87a346fd6d61..183dfe2191c6 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -488,13 +488,13 @@ static void sync_cmos_clock(struct work_struct *work) | |||
488 | 488 | ||
489 | getnstimeofday64(&now); | 489 | getnstimeofday64(&now); |
490 | if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec * 5) { | 490 | if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec * 5) { |
491 | struct timespec adjust = timespec64_to_timespec(now); | 491 | struct timespec64 adjust = now; |
492 | 492 | ||
493 | fail = -ENODEV; | 493 | fail = -ENODEV; |
494 | if (persistent_clock_is_local) | 494 | if (persistent_clock_is_local) |
495 | adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); | 495 | adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); |
496 | #ifdef CONFIG_GENERIC_CMOS_UPDATE | 496 | #ifdef CONFIG_GENERIC_CMOS_UPDATE |
497 | fail = update_persistent_clock(adjust); | 497 | fail = update_persistent_clock(timespec64_to_timespec(adjust)); |
498 | #endif | 498 | #endif |
499 | #ifdef CONFIG_RTC_SYSTOHC | 499 | #ifdef CONFIG_RTC_SYSTOHC |
500 | if (fail == -ENODEV) | 500 | if (fail == -ENODEV) |