diff options
author | John Stultz <john.stultz@linaro.org> | 2014-11-21 00:06:12 -0500 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2014-11-21 15:00:00 -0500 |
commit | d4bda8f843a4667f3800dd0eff116c65360deeef (patch) | |
tree | b03a3c330646b795768f83897f31297ff4ff7a47 /drivers/rtc | |
parent | c2c11ae4b6bc03b41720337028b940cbec9e316f (diff) |
rtc: Update suspend/resume timing to use 64bit time
Currently the rtc suspend/resume timing is done using
y2038 problematic timespecs. So update the code to utilize
timespec64 types.
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/class.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 38e26be705be..472a5adc4642 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -45,14 +45,14 @@ int rtc_hctosys_ret = -ENODEV; | |||
45 | * system's wall clock; restore it on resume(). | 45 | * system's wall clock; restore it on resume(). |
46 | */ | 46 | */ |
47 | 47 | ||
48 | static struct timespec old_rtc, old_system, old_delta; | 48 | static struct timespec64 old_rtc, old_system, old_delta; |
49 | 49 | ||
50 | 50 | ||
51 | static int rtc_suspend(struct device *dev) | 51 | static int rtc_suspend(struct device *dev) |
52 | { | 52 | { |
53 | struct rtc_device *rtc = to_rtc_device(dev); | 53 | struct rtc_device *rtc = to_rtc_device(dev); |
54 | struct rtc_time tm; | 54 | struct rtc_time tm; |
55 | struct timespec delta, delta_delta; | 55 | struct timespec64 delta, delta_delta; |
56 | int err; | 56 | int err; |
57 | 57 | ||
58 | if (has_persistent_clock()) | 58 | if (has_persistent_clock()) |
@@ -68,8 +68,8 @@ static int rtc_suspend(struct device *dev) | |||
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | getnstimeofday(&old_system); | 71 | getnstimeofday64(&old_system); |
72 | rtc_tm_to_time(&tm, &old_rtc.tv_sec); | 72 | old_rtc.tv_sec = rtc_tm_to_time64(&tm); |
73 | 73 | ||
74 | 74 | ||
75 | /* | 75 | /* |
@@ -78,8 +78,8 @@ static int rtc_suspend(struct device *dev) | |||
78 | * try to compensate so the difference in system time | 78 | * try to compensate so the difference in system time |
79 | * and rtc time stays close to constant. | 79 | * and rtc time stays close to constant. |
80 | */ | 80 | */ |
81 | delta = timespec_sub(old_system, old_rtc); | 81 | delta = timespec64_sub(old_system, old_rtc); |
82 | delta_delta = timespec_sub(delta, old_delta); | 82 | delta_delta = timespec64_sub(delta, old_delta); |
83 | if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) { | 83 | if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) { |
84 | /* | 84 | /* |
85 | * if delta_delta is too large, assume time correction | 85 | * if delta_delta is too large, assume time correction |
@@ -88,7 +88,7 @@ static int rtc_suspend(struct device *dev) | |||
88 | old_delta = delta; | 88 | old_delta = delta; |
89 | } else { | 89 | } else { |
90 | /* Otherwise try to adjust old_system to compensate */ | 90 | /* Otherwise try to adjust old_system to compensate */ |
91 | old_system = timespec_sub(old_system, delta_delta); | 91 | old_system = timespec64_sub(old_system, delta_delta); |
92 | } | 92 | } |
93 | 93 | ||
94 | return 0; | 94 | return 0; |
@@ -98,8 +98,8 @@ static int rtc_resume(struct device *dev) | |||
98 | { | 98 | { |
99 | struct rtc_device *rtc = to_rtc_device(dev); | 99 | struct rtc_device *rtc = to_rtc_device(dev); |
100 | struct rtc_time tm; | 100 | struct rtc_time tm; |
101 | struct timespec new_system, new_rtc; | 101 | struct timespec64 new_system, new_rtc; |
102 | struct timespec sleep_time; | 102 | struct timespec64 sleep_time; |
103 | int err; | 103 | int err; |
104 | 104 | ||
105 | if (has_persistent_clock()) | 105 | if (has_persistent_clock()) |
@@ -110,7 +110,7 @@ static int rtc_resume(struct device *dev) | |||
110 | return 0; | 110 | return 0; |
111 | 111 | ||
112 | /* snapshot the current rtc and system time at resume */ | 112 | /* snapshot the current rtc and system time at resume */ |
113 | getnstimeofday(&new_system); | 113 | getnstimeofday64(&new_system); |
114 | err = rtc_read_time(rtc, &tm); | 114 | err = rtc_read_time(rtc, &tm); |
115 | if (err < 0) { | 115 | if (err < 0) { |
116 | pr_debug("%s: fail to read rtc time\n", dev_name(&rtc->dev)); | 116 | pr_debug("%s: fail to read rtc time\n", dev_name(&rtc->dev)); |
@@ -121,7 +121,7 @@ static int rtc_resume(struct device *dev) | |||
121 | pr_debug("%s: bogus resume time\n", dev_name(&rtc->dev)); | 121 | pr_debug("%s: bogus resume time\n", dev_name(&rtc->dev)); |
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | rtc_tm_to_time(&tm, &new_rtc.tv_sec); | 124 | new_rtc.tv_sec = rtc_tm_to_time64(&tm); |
125 | new_rtc.tv_nsec = 0; | 125 | new_rtc.tv_nsec = 0; |
126 | 126 | ||
127 | if (new_rtc.tv_sec < old_rtc.tv_sec) { | 127 | if (new_rtc.tv_sec < old_rtc.tv_sec) { |
@@ -130,7 +130,7 @@ static int rtc_resume(struct device *dev) | |||
130 | } | 130 | } |
131 | 131 | ||
132 | /* calculate the RTC time delta (sleep time)*/ | 132 | /* calculate the RTC time delta (sleep time)*/ |
133 | sleep_time = timespec_sub(new_rtc, old_rtc); | 133 | sleep_time = timespec64_sub(new_rtc, old_rtc); |
134 | 134 | ||
135 | /* | 135 | /* |
136 | * Since these RTC suspend/resume handlers are not called | 136 | * Since these RTC suspend/resume handlers are not called |
@@ -139,11 +139,11 @@ static int rtc_resume(struct device *dev) | |||
139 | * so subtract kernel run-time between rtc_suspend to rtc_resume | 139 | * so subtract kernel run-time between rtc_suspend to rtc_resume |
140 | * to keep things accurate. | 140 | * to keep things accurate. |
141 | */ | 141 | */ |
142 | sleep_time = timespec_sub(sleep_time, | 142 | sleep_time = timespec64_sub(sleep_time, |
143 | timespec_sub(new_system, old_system)); | 143 | timespec64_sub(new_system, old_system)); |
144 | 144 | ||
145 | if (sleep_time.tv_sec >= 0) | 145 | if (sleep_time.tv_sec >= 0) |
146 | timekeeping_inject_sleeptime(&sleep_time); | 146 | timekeeping_inject_sleeptime64(&sleep_time); |
147 | rtc_hctosys_ret = 0; | 147 | rtc_hctosys_ret = 0; |
148 | return 0; | 148 | return 0; |
149 | } | 149 | } |