From: Xunlei Pang <xlpang@126.com>
To: linux-kernel@vger.kernel.org,
John Stultz <john.stultz@linaro.org>,
Arnd Bergmann <arnd.bergmann@linaro.org>
Cc: rtc-linux@googlegroups.com, Thomas Gleixner <tglx@linutronix.de>,
Alessandro Zummo <a.zummo@towertech.it>,
Xunlei Pang <pang.xunlei@linaro.org>
Subject: [RFC PATCH v2 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement
Date: Tue, 13 Jan 2015 23:44:49 +0800 [thread overview]
Message-ID: <1421163897-8020-2-git-send-email-xlpang@126.com> (raw)
In-Reply-To: <1421163897-8020-1-git-send-email-xlpang@126.com>
From: Xunlei Pang <pang.xunlei@linaro.org>
Currently the rtc_class_op's set_mmss() function takes a 32bit second
value (on 32bit systems), which is problematic for dates past y2038.
This patch provides a safe version named set_mmss64() using y2038 safe
time64_t.
After this patch, set_mmss() is deprecated and all its users will be
fixed to use set_mmss64(), it can be removed when having no users.
Cc: John Stultz <john.stultz@linaro.org>
Cc: Arnd Bergmann <arnd.bergmann@linaro.org>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
drivers/rtc/interface.c | 9 ++++++++-
drivers/rtc/systohc.c | 5 ++++-
include/linux/rtc.h | 1 +
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 45bfc28ee..fca7882 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -72,7 +72,12 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
err = -ENODEV;
else if (rtc->ops->set_time)
err = rtc->ops->set_time(rtc->dev.parent, tm);
- else if (rtc->ops->set_mmss) {
+ else if (rtc->ops->set_mmss64) {
+ time64_t secs64;
+
+ secs64 = rtc_tm_to_time64(tm);
+ err = rtc->ops->set_mmss64(rtc->dev.parent, secs64);
+ } else if (rtc->ops->set_mmss) {
unsigned long secs;
err = rtc_tm_to_time(tm, &secs);
if (err == 0)
@@ -98,6 +103,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
if (!rtc->ops)
err = -ENODEV;
+ else if (rtc->ops->set_mmss64)
+ err = rtc->ops->set_mmss64(rtc->dev.parent, secs);
else if (rtc->ops->set_mmss)
err = rtc->ops->set_mmss(rtc->dev.parent, secs);
else if (rtc->ops->read_time && rtc->ops->set_time) {
diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c
index bf3e242..e34a07b 100644
--- a/drivers/rtc/systohc.c
+++ b/drivers/rtc/systohc.c
@@ -35,7 +35,10 @@ int rtc_set_ntp_time(struct timespec now)
if (rtc) {
/* rtc_hctosys exclusively uses UTC, so we call set_time here,
* not set_mmss. */
- if (rtc->ops && (rtc->ops->set_time || rtc->ops->set_mmss))
+ if (rtc->ops &&
+ (rtc->ops->set_time ||
+ rtc->ops->set_mmss64 ||
+ rtc->ops->set_mmss))
err = rtc_set_time(rtc, &tm);
rtc_class_close(rtc);
}
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 6d6be09..29093da 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -77,6 +77,7 @@ struct rtc_class_ops {
int (*read_alarm)(struct device *, struct rtc_wkalrm *);
int (*set_alarm)(struct device *, struct rtc_wkalrm *);
int (*proc)(struct device *, struct seq_file *);
+ int (*set_mmss64)(struct device *, time64_t secs);
int (*set_mmss)(struct device *, unsigned long secs);
int (*read_callback)(struct device *, int data);
int (*alarm_irq_enable)(struct device *, unsigned int enabled);
--
1.9.1
next prev parent reply other threads:[~2015-01-13 15:51 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 15:44 [RFC PATCH v2 0/9] Provide y2038/y2106 safe rtc_class_ops.set_mmss64() Xunlei Pang
2015-01-13 15:44 ` Xunlei Pang [this message]
2015-01-13 16:12 ` [RFC PATCH v2 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement Alessandro Zummo
2015-01-13 15:44 ` [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement Xunlei Pang
2015-01-13 16:17 ` Alessandro Zummo
2015-01-13 20:34 ` Arnd Bergmann
2015-01-13 20:42 ` Thomas Gleixner
2015-01-14 14:52 ` Xunlei Pang
2015-01-13 15:44 ` [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues Xunlei Pang
2015-01-13 16:19 ` Alessandro Zummo
2015-01-14 14:56 ` Xunlei Pang
2015-01-14 15:03 ` Alessandro Zummo
2015-01-14 15:26 ` Xunlei Pang
2015-01-14 15:39 ` Alessandro Zummo
2015-01-16 15:40 ` Xunlei Pang
2015-01-13 15:44 ` [RFC PATCH v2 4/9] rtc/ab3100: " Xunlei Pang
2015-01-13 16:20 ` Alessandro Zummo
2015-01-15 17:23 ` Linus Walleij
2015-01-13 15:44 ` [RFC PATCH v2 5/9] rtc/mc13xxx: " Xunlei Pang
2015-01-14 15:07 ` Xunlei Pang
2015-01-14 17:03 ` Uwe Kleine-König
2015-01-13 15:44 ` [RFC PATCH v2 6/9] rtc/mxc: Modify rtc_update_alarm() not to touch the alarm time Xunlei Pang
2015-01-13 16:23 ` Alessandro Zummo
2015-01-14 15:13 ` Xunlei Pang
2015-01-13 15:44 ` [RFC PATCH v2 7/9] rtc/mxc: Convert get_alarm_or_time()/set_alarm_or_time() to use time64_t Xunlei Pang
2015-01-13 15:44 ` [RFC PATCH v2 8/9] rtc/mxc: Update driver to address y2038/y2106 issues Xunlei Pang
2015-01-13 15:44 ` [RFC PATCH v2 9/9] alpha: change to use rtc_class_ops's set_mmss64() Xunlei Pang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421163897-8020-2-git-send-email-xlpang@126.com \
--to=xlpang@126.com \
--cc=a.zummo@towertech.it \
--cc=arnd.bergmann@linaro.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pang.xunlei@linaro.org \
--cc=rtc-linux@googlegroups.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome