* [PATCH] rtc: Use time64_t variables to set time/alarm from sysfs
@ 2017-11-09 7:09 Baolin Wang
2017-11-09 10:38 ` Arnd Bergmann
2017-11-10 8:58 ` Alexandre Belloni
0 siblings, 2 replies; 3+ messages in thread
From: Baolin Wang @ 2017-11-09 7:09 UTC (permalink / raw)
To: a.zummo, alexandre.belloni
Cc: linux-rtc, linux-kernel, arnd, broonie, baolin.wang
Use time64_t variables and related APIs for sysfs interfaces to
support setting time or alarm after the year 2038 on 32-bit system.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
drivers/rtc/rtc-sysfs.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index e364550..92ff2ed 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -72,9 +72,10 @@
retval = rtc_read_time(to_rtc_device(dev), &tm);
if (retval == 0) {
- unsigned long time;
- rtc_tm_to_time(&tm, &time);
- retval = sprintf(buf, "%lu\n", time);
+ time64_t time;
+
+ time = rtc_tm_to_time64(&tm);
+ retval = sprintf(buf, "%lld\n", time);
}
return retval;
@@ -132,7 +133,7 @@
wakealarm_show(struct device *dev, struct device_attribute *attr, char *buf)
{
ssize_t retval;
- unsigned long alarm;
+ time64_t alarm;
struct rtc_wkalrm alm;
/* Don't show disabled alarms. For uniformity, RTC alarms are
@@ -145,8 +146,8 @@
*/
retval = rtc_read_alarm(to_rtc_device(dev), &alm);
if (retval == 0 && alm.enabled) {
- rtc_tm_to_time(&alm.time, &alarm);
- retval = sprintf(buf, "%lu\n", alarm);
+ alarm = rtc_tm_to_time64(&alm.time);
+ retval = sprintf(buf, "%lld\n", alarm);
}
return retval;
@@ -157,8 +158,8 @@
const char *buf, size_t n)
{
ssize_t retval;
- unsigned long now, alarm;
- unsigned long push = 0;
+ time64_t now, alarm;
+ time64_t push = 0;
struct rtc_wkalrm alm;
struct rtc_device *rtc = to_rtc_device(dev);
const char *buf_ptr;
@@ -170,7 +171,7 @@
retval = rtc_read_time(rtc, &alm.time);
if (retval < 0)
return retval;
- rtc_tm_to_time(&alm.time, &now);
+ now = rtc_tm_to_time64(&alm.time);
buf_ptr = buf;
if (*buf_ptr == '+') {
@@ -181,7 +182,7 @@
} else
adjust = 1;
}
- retval = kstrtoul(buf_ptr, 0, &alarm);
+ retval = kstrtos64(buf_ptr, 0, &alarm);
if (retval)
return retval;
if (adjust) {
@@ -197,7 +198,7 @@
return retval;
if (alm.enabled) {
if (push) {
- rtc_tm_to_time(&alm.time, &push);
+ push = rtc_tm_to_time64(&alm.time);
alarm += push;
} else
return -EBUSY;
@@ -212,7 +213,7 @@
*/
alarm = now + 300;
}
- rtc_time_to_tm(alarm, &alm.time);
+ rtc_time64_to_tm(alarm, &alm.time);
retval = rtc_set_alarm(rtc, &alm);
return (retval < 0) ? retval : n;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rtc: Use time64_t variables to set time/alarm from sysfs
2017-11-09 7:09 [PATCH] rtc: Use time64_t variables to set time/alarm from sysfs Baolin Wang
@ 2017-11-09 10:38 ` Arnd Bergmann
2017-11-10 8:58 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-11-09 10:38 UTC (permalink / raw)
To: Baolin Wang
Cc: Alessandro Zummo, Alexandre Belloni, linux-rtc,
Linux Kernel Mailing List, Mark Brown
On Thu, Nov 9, 2017 at 8:09 AM, Baolin Wang <baolin.wang@linaro.org> wrote:
> Use time64_t variables and related APIs for sysfs interfaces to
> support setting time or alarm after the year 2038 on 32-bit system.
>
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Looks good,
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rtc: Use time64_t variables to set time/alarm from sysfs
2017-11-09 7:09 [PATCH] rtc: Use time64_t variables to set time/alarm from sysfs Baolin Wang
2017-11-09 10:38 ` Arnd Bergmann
@ 2017-11-10 8:58 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2017-11-10 8:58 UTC (permalink / raw)
To: Baolin Wang; +Cc: a.zummo, linux-rtc, linux-kernel, arnd, broonie
On 09/11/2017 at 15:09:20 +0800, Baolin Wang wrote:
> Use time64_t variables and related APIs for sysfs interfaces to
> support setting time or alarm after the year 2038 on 32-bit system.
>
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> ---
> drivers/rtc/rtc-sysfs.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
Applied, thanks.
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-10 8:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 7:09 [PATCH] rtc: Use time64_t variables to set time/alarm from sysfs Baolin Wang
2017-11-09 10:38 ` Arnd Bergmann
2017-11-10 8:58 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).