diff options
author | Xunlei Pang <pang.xunlei@linaro.org> | 2015-04-01 23:34:32 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-04-03 02:18:28 -0400 |
commit | a015b8aabfd2fb58875dea001f1eac8100eacc2e (patch) | |
tree | 34514f71a00e35e2ab28b06351dc81d83df5fd44 /drivers/rtc/rtc-mxc.c | |
parent | 482494a8d395877c4776a3d76f89342d7ad7c4c6 (diff) |
drivers/rtc/mxc: Convert get_alarm_or_time()/set_alarm_or_time() to use time64_t
We want to convert mxc_rtc_set_mmss() to use rtc_class_ops's
set_mmss64(), but it uses get_alarm_or_time()/set_alarm_or_time()
internal interfaces which are y2038 unsafe.
So here as a separate patch, it converts these two internal
interfaces of "mxc" to use safe time64_t to make some
preparations.
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1427945681-29972-13-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/rtc/rtc-mxc.c')
-rw-r--r-- | drivers/rtc/rtc-mxc.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index a7b218ff078d..83cba23a6b00 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
@@ -106,7 +106,7 @@ static inline int is_imx1_rtc(struct rtc_plat_data *data) | |||
106 | * This function is used to obtain the RTC time or the alarm value in | 106 | * This function is used to obtain the RTC time or the alarm value in |
107 | * second. | 107 | * second. |
108 | */ | 108 | */ |
109 | static u32 get_alarm_or_time(struct device *dev, int time_alarm) | 109 | static time64_t get_alarm_or_time(struct device *dev, int time_alarm) |
110 | { | 110 | { |
111 | struct platform_device *pdev = to_platform_device(dev); | 111 | struct platform_device *pdev = to_platform_device(dev); |
112 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 112 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
@@ -129,29 +129,28 @@ static u32 get_alarm_or_time(struct device *dev, int time_alarm) | |||
129 | hr = hr_min >> 8; | 129 | hr = hr_min >> 8; |
130 | min = hr_min & 0xff; | 130 | min = hr_min & 0xff; |
131 | 131 | ||
132 | return (((day * 24 + hr) * 60) + min) * 60 + sec; | 132 | return ((((time64_t)day * 24 + hr) * 60) + min) * 60 + sec; |
133 | } | 133 | } |
134 | 134 | ||
135 | /* | 135 | /* |
136 | * This function sets the RTC alarm value or the time value. | 136 | * This function sets the RTC alarm value or the time value. |
137 | */ | 137 | */ |
138 | static void set_alarm_or_time(struct device *dev, int time_alarm, u32 time) | 138 | static void set_alarm_or_time(struct device *dev, int time_alarm, time64_t time) |
139 | { | 139 | { |
140 | u32 day, hr, min, sec, temp; | 140 | u32 tod, day, hr, min, sec, temp; |
141 | struct platform_device *pdev = to_platform_device(dev); | 141 | struct platform_device *pdev = to_platform_device(dev); |
142 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 142 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
143 | void __iomem *ioaddr = pdata->ioaddr; | 143 | void __iomem *ioaddr = pdata->ioaddr; |
144 | 144 | ||
145 | day = time / 86400; | 145 | day = div_s64_rem(time, 86400, &tod); |
146 | time -= day * 86400; | ||
147 | 146 | ||
148 | /* time is within a day now */ | 147 | /* time is within a day now */ |
149 | hr = time / 3600; | 148 | hr = tod / 3600; |
150 | time -= hr * 3600; | 149 | tod -= hr * 3600; |
151 | 150 | ||
152 | /* time is within an hour now */ | 151 | /* time is within an hour now */ |
153 | min = time / 60; | 152 | min = tod / 60; |
154 | sec = time - min * 60; | 153 | sec = tod - min * 60; |
155 | 154 | ||
156 | temp = (hr << 8) + min; | 155 | temp = (hr << 8) + min; |
157 | 156 | ||
@@ -175,12 +174,12 @@ static void set_alarm_or_time(struct device *dev, int time_alarm, u32 time) | |||
175 | */ | 174 | */ |
176 | static void rtc_update_alarm(struct device *dev, struct rtc_time *alrm) | 175 | static void rtc_update_alarm(struct device *dev, struct rtc_time *alrm) |
177 | { | 176 | { |
178 | unsigned long time; | 177 | time64_t time; |
179 | struct platform_device *pdev = to_platform_device(dev); | 178 | struct platform_device *pdev = to_platform_device(dev); |
180 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 179 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
181 | void __iomem *ioaddr = pdata->ioaddr; | 180 | void __iomem *ioaddr = pdata->ioaddr; |
182 | 181 | ||
183 | rtc_tm_to_time(alrm, &time); | 182 | time = rtc_tm_to_time64(alrm); |
184 | 183 | ||
185 | /* clear all the interrupt status bits */ | 184 | /* clear all the interrupt status bits */ |
186 | writew(readw(ioaddr + RTC_RTCISR), ioaddr + RTC_RTCISR); | 185 | writew(readw(ioaddr + RTC_RTCISR), ioaddr + RTC_RTCISR); |
@@ -272,14 +271,14 @@ static int mxc_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
272 | */ | 271 | */ |
273 | static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm) | 272 | static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm) |
274 | { | 273 | { |
275 | u32 val; | 274 | time64_t val; |
276 | 275 | ||
277 | /* Avoid roll-over from reading the different registers */ | 276 | /* Avoid roll-over from reading the different registers */ |
278 | do { | 277 | do { |
279 | val = get_alarm_or_time(dev, MXC_RTC_TIME); | 278 | val = get_alarm_or_time(dev, MXC_RTC_TIME); |
280 | } while (val != get_alarm_or_time(dev, MXC_RTC_TIME)); | 279 | } while (val != get_alarm_or_time(dev, MXC_RTC_TIME)); |
281 | 280 | ||
282 | rtc_time_to_tm(val, tm); | 281 | rtc_time64_to_tm(val, tm); |
283 | 282 | ||
284 | return 0; | 283 | return 0; |
285 | } | 284 | } |
@@ -322,7 +321,7 @@ static int mxc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
322 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 321 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
323 | void __iomem *ioaddr = pdata->ioaddr; | 322 | void __iomem *ioaddr = pdata->ioaddr; |
324 | 323 | ||
325 | rtc_time_to_tm(get_alarm_or_time(dev, MXC_RTC_ALARM), &alrm->time); | 324 | rtc_time64_to_tm(get_alarm_or_time(dev, MXC_RTC_ALARM), &alrm->time); |
326 | alrm->pending = ((readw(ioaddr + RTC_RTCISR) & RTC_ALM_BIT)) ? 1 : 0; | 325 | alrm->pending = ((readw(ioaddr + RTC_RTCISR) & RTC_ALM_BIT)) ? 1 : 0; |
327 | 326 | ||
328 | return 0; | 327 | return 0; |