Skip to content

Commit 9a4a445

Browse files
Xunlei Pangjohnstultz-work
authored andcommitted
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 <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Signed-off-by: Xunlei Pang <[email protected]> Signed-off-by: John Stultz <[email protected]>
1 parent 966301a commit 9a4a445

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

drivers/rtc/systohc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
*
2121
* If temporary failure is indicated the caller should try again 'soon'
2222
*/
23-
int rtc_set_ntp_time(struct timespec now)
23+
int rtc_set_ntp_time(struct timespec64 now)
2424
{
2525
struct rtc_device *rtc;
2626
struct rtc_time tm;
2727
int err = -ENODEV;
2828

2929
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);
3131
else
32-
rtc_time_to_tm(now.tv_sec + 1, &tm);
32+
rtc_time64_to_tm(now.tv_sec + 1, &tm);
3333

3434
rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
3535
if (rtc) {

include/linux/rtc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ extern void devm_rtc_device_unregister(struct device *dev,
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);

kernel/time/ntp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,13 @@ static void sync_cmos_clock(struct work_struct *work)
488488

489489
getnstimeofday64(&now);
490490
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;
492492

493493
fail = -ENODEV;
494494
if (persistent_clock_is_local)
495495
adjust.tv_sec -= (sys_tz.tz_minuteswest * 60);
496496
#ifdef CONFIG_GENERIC_CMOS_UPDATE
497-
fail = update_persistent_clock(adjust);
497+
fail = update_persistent_clock(timespec64_to_timespec(adjust));
498498
#endif
499499
#ifdef CONFIG_RTC_SYSTOHC
500500
if (fail == -ENODEV)

0 commit comments

Comments
 (0)