* [RFC PATCH v2 0/9] Provide y2038/y2106 safe rtc_class_ops.set_mmss64()
@ 2015-01-13 15:44 Xunlei Pang
2015-01-13 15:44 ` [RFC PATCH v2 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement Xunlei Pang
` (8 more replies)
0 siblings, 9 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
From: Xunlei Pang <pang.xunlei@linaro.org>
This patch series relies on a former patchset[1], it provides y2038/y2106
safe rtc_class_ops.set_mmss64(), and converts some possible users of set_mmss()
to use set_mmss64(), in the hope that making these users(i.e. rtc drivers)
y2038/y2106 safe.
The first version of this patchset is: [2].
[1] https://lkml.org/lkml/2014/11/18/218
[2] https://lkml.org/lkml/2014/11/27/341
Xunlei Pang (9):
rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement
time: Provide y2106 safe get_seconds() replacement
rtc/test: Update driver to address y2038/y2106 issues
rtc/ab3100: Update driver to address y2038/y2106 issues
rtc/mc13xxx: Update driver to address y2038/y2106 issues
rtc/mxc: Modify rtc_update_alarm() not to touch the alarm time
rtc/mxc: Convert get_alarm_or_time()/set_alarm_or_time() to use
time64_t
rtc/mxc: Update driver to address y2038/y2106 issues
alpha: change to use rtc_class_ops's set_mmss64()
arch/alpha/kernel/rtc.c | 8 +++----
drivers/rtc/interface.c | 9 +++++++-
drivers/rtc/rtc-ab3100.c | 55 ++++++++++++++++++++++-----------------------
drivers/rtc/rtc-mc13xxx.c | 32 ++++++++++++--------------
drivers/rtc/rtc-mxc.c | 55 +++++++++++++++++----------------------------
drivers/rtc/rtc-test.c | 8 +++----
drivers/rtc/systohc.c | 5 ++++-
include/linux/rtc.h | 1 +
include/linux/timekeeping.h | 10 ++++++++-
kernel/time/timekeeping.c | 4 ++--
10 files changed, 93 insertions(+), 94 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [RFC PATCH v2 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement
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
2015-01-13 16:12 ` Alessandro Zummo
2015-01-13 15:44 ` [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement Xunlei Pang
` (7 subsequent siblings)
8 siblings, 1 reply; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
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
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
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 ` [RFC PATCH v2 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement Xunlei Pang
@ 2015-01-13 15:44 ` Xunlei Pang
2015-01-13 16:17 ` Alessandro Zummo
2015-01-13 20:42 ` Thomas Gleixner
2015-01-13 15:44 ` [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues Xunlei Pang
` (6 subsequent siblings)
8 siblings, 2 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
From: Xunlei Pang <pang.xunlei@linaro.org>
As part of addressing "y2038 problem" for in-kernel uses, this
patch adds safe get_seconds64() using time64_t.
After this patch, get_seconds() is deprecated and all its call sites
will be fixed using get_seconds64(), after that it can be removed.
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
include/linux/timekeeping.h | 10 +++++++++-
kernel/time/timekeeping.c | 4 ++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 9b63d13..384d101 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -17,7 +17,7 @@ extern int do_sys_settimeofday(const struct timespec *tv,
/*
* Kernel time accessors
*/
-unsigned long get_seconds(void);
+extern time64_t get_seconds64(void);
struct timespec current_kernel_time(void);
/* does not take xtime_lock */
struct timespec __current_kernel_time(void);
@@ -34,6 +34,14 @@ extern time64_t ktime_get_real_seconds(void);
extern int __getnstimeofday64(struct timespec64 *tv);
extern void getnstimeofday64(struct timespec64 *tv);
+/**
+ * Deprecated. Use get_seconds64().
+ */
+static inline unsigned long get_seconds(void)
+{
+ return (unsigned long)get_seconds64();
+}
+
#if BITS_PER_LONG == 64
/**
* Deprecated. Use do_settimeofday64().
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 6a93185..ab021a3 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1678,13 +1678,13 @@ void getboottime(struct timespec *ts)
}
EXPORT_SYMBOL_GPL(getboottime);
-unsigned long get_seconds(void)
+time64_t get_seconds64(void)
{
struct timekeeper *tk = &tk_core.timekeeper;
return tk->xtime_sec;
}
-EXPORT_SYMBOL(get_seconds);
+EXPORT_SYMBOL(get_seconds64);
struct timespec __current_kernel_time(void)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues
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 ` [RFC PATCH v2 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement Xunlei Pang
2015-01-13 15:44 ` [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement Xunlei Pang
@ 2015-01-13 15:44 ` Xunlei Pang
2015-01-13 16:19 ` Alessandro Zummo
2015-01-13 15:44 ` [RFC PATCH v2 4/9] rtc/ab3100: " Xunlei Pang
` (5 subsequent siblings)
8 siblings, 1 reply; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
From: Xunlei Pang <pang.xunlei@linaro.org>
This driver has a number of y2038/y2106 issues.
This patch resolves them by:
- Repalce get_seconds() with get_seconds64()
- Replace rtc_time_to_tm() with rtc_time64_to_tm()
- Change test_rtc_set_mmss() to use rtc_class_ops's set_mmss64()
After this patch, this driver should not have any remaining
y2038/y2106 issues.
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
drivers/rtc/rtc-test.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index 8f86fa9..056138b 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -30,13 +30,13 @@ static int test_rtc_set_alarm(struct device *dev,
static int test_rtc_read_time(struct device *dev,
struct rtc_time *tm)
{
- rtc_time_to_tm(get_seconds(), tm);
+ rtc_time64_to_tm(get_seconds64(), tm);
return 0;
}
-static int test_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int test_rtc_set_mmss(struct device *dev, time64_t secs)
{
- dev_info(dev, "%s, secs = %lu\n", __func__, secs);
+ dev_info(dev, "%s, secs = %lld\n", __func__, (long long)secs);
return 0;
}
@@ -60,7 +60,7 @@ static const struct rtc_class_ops test_rtc_ops = {
.read_time = test_rtc_read_time,
.read_alarm = test_rtc_read_alarm,
.set_alarm = test_rtc_set_alarm,
- .set_mmss = test_rtc_set_mmss,
+ .set_mmss64 = test_rtc_set_mmss,
.alarm_irq_enable = test_rtc_alarm_irq_enable,
};
--
1.9.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [RFC PATCH v2 4/9] rtc/ab3100: Update driver to address y2038/y2106 issues
2015-01-13 15:44 [RFC PATCH v2 0/9] Provide y2038/y2106 safe rtc_class_ops.set_mmss64() Xunlei Pang
` (2 preceding siblings ...)
2015-01-13 15:44 ` [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues Xunlei Pang
@ 2015-01-13 15:44 ` 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
` (4 subsequent siblings)
8 siblings, 2 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
From: Xunlei Pang <pang.xunlei@linaro.org>
This driver has a number of y2038/y2106 issues.
This patch resolves them by:
- Replace rtc_tm_to_time() with rtc_tm_to_time64()
- Replace rtc_time_to_tm() with rtc_time64_to_tm()
- Change ab3100_rtc_set_mmss() to use rtc_class_ops's set_mmss64()
After this patch, the driver should not have any remaining
y2038/y2106 issues.
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
drivers/rtc/rtc-ab3100.c | 55 ++++++++++++++++++++++++------------------------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/drivers/rtc/rtc-ab3100.c b/drivers/rtc/rtc-ab3100.c
index 1d0340f..9b725c5 100644
--- a/drivers/rtc/rtc-ab3100.c
+++ b/drivers/rtc/rtc-ab3100.c
@@ -43,21 +43,21 @@
/*
* RTC clock functions and device struct declaration
*/
-static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int ab3100_rtc_set_mmss(struct device *dev, time64_t secs)
{
u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2,
AB3100_TI3, AB3100_TI4, AB3100_TI5};
unsigned char buf[6];
- u64 fat_time = (u64) secs * AB3100_RTC_CLOCK_RATE * 2;
+ u64 hw_counter = secs * AB3100_RTC_CLOCK_RATE * 2;
int err = 0;
int i;
- buf[0] = (fat_time) & 0xFF;
- buf[1] = (fat_time >> 8) & 0xFF;
- buf[2] = (fat_time >> 16) & 0xFF;
- buf[3] = (fat_time >> 24) & 0xFF;
- buf[4] = (fat_time >> 32) & 0xFF;
- buf[5] = (fat_time >> 40) & 0xFF;
+ buf[0] = (hw_counter) & 0xFF;
+ buf[1] = (hw_counter >> 8) & 0xFF;
+ buf[2] = (hw_counter >> 16) & 0xFF;
+ buf[3] = (hw_counter >> 24) & 0xFF;
+ buf[4] = (hw_counter >> 32) & 0xFF;
+ buf[5] = (hw_counter >> 40) & 0xFF;
for (i = 0; i < 6; i++) {
err = abx500_set_register_interruptible(dev, 0,
@@ -75,7 +75,7 @@ static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs)
static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
- unsigned long time;
+ time64_t time;
u8 rtcval;
int err;
@@ -88,7 +88,7 @@ static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
dev_info(dev, "clock not set (lost power)");
return -EINVAL;
} else {
- u64 fat_time;
+ u64 hw_counter;
u8 buf[6];
/* Read out time registers */
@@ -98,22 +98,21 @@ static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
if (err != 0)
return err;
- fat_time = ((u64) buf[5] << 40) | ((u64) buf[4] << 32) |
+ hw_counter = ((u64) buf[5] << 40) | ((u64) buf[4] << 32) |
((u64) buf[3] << 24) | ((u64) buf[2] << 16) |
((u64) buf[1] << 8) | (u64) buf[0];
- time = (unsigned long) (fat_time /
- (u64) (AB3100_RTC_CLOCK_RATE * 2));
+ time = hw_counter / (u64) (AB3100_RTC_CLOCK_RATE * 2);
}
- rtc_time_to_tm(time, tm);
+ rtc_time64_to_tm(time, tm);
return rtc_valid_tm(tm);
}
static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
- unsigned long time;
- u64 fat_time;
+ time64_t time;
+ u64 hw_counter;
u8 buf[6];
u8 rtcval;
int err;
@@ -134,11 +133,11 @@ static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
AB3100_AL0, buf, 4);
if (err)
return err;
- fat_time = ((u64) buf[3] << 40) | ((u64) buf[2] << 32) |
+ hw_counter = ((u64) buf[3] << 40) | ((u64) buf[2] << 32) |
((u64) buf[1] << 24) | ((u64) buf[0] << 16);
- time = (unsigned long) (fat_time / (u64) (AB3100_RTC_CLOCK_RATE * 2));
+ time = hw_counter / (u64) (AB3100_RTC_CLOCK_RATE * 2);
- rtc_time_to_tm(time, &alarm->time);
+ rtc_time64_to_tm(time, &alarm->time);
return rtc_valid_tm(&alarm->time);
}
@@ -147,17 +146,17 @@ static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
u8 regs[] = {AB3100_AL0, AB3100_AL1, AB3100_AL2, AB3100_AL3};
unsigned char buf[4];
- unsigned long secs;
- u64 fat_time;
+ time64_t secs;
+ u64 hw_counter;
int err;
int i;
- rtc_tm_to_time(&alarm->time, &secs);
- fat_time = (u64) secs * AB3100_RTC_CLOCK_RATE * 2;
- buf[0] = (fat_time >> 16) & 0xFF;
- buf[1] = (fat_time >> 24) & 0xFF;
- buf[2] = (fat_time >> 32) & 0xFF;
- buf[3] = (fat_time >> 40) & 0xFF;
+ secs = rtc_tm_to_time64(&alarm->time);
+ hw_counter = secs * AB3100_RTC_CLOCK_RATE * 2;
+ buf[0] = (hw_counter >> 16) & 0xFF;
+ buf[1] = (hw_counter >> 24) & 0xFF;
+ buf[2] = (hw_counter >> 32) & 0xFF;
+ buf[3] = (hw_counter >> 40) & 0xFF;
/* Set the alarm */
for (i = 0; i < 4; i++) {
@@ -193,7 +192,7 @@ static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled)
static const struct rtc_class_ops ab3100_rtc_ops = {
.read_time = ab3100_rtc_read_time,
- .set_mmss = ab3100_rtc_set_mmss,
+ .set_mmss64 = ab3100_rtc_set_mmss,
.read_alarm = ab3100_rtc_read_alarm,
.set_alarm = ab3100_rtc_set_alarm,
.alarm_irq_enable = ab3100_rtc_irq_enable,
--
1.9.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [RFC PATCH v2 5/9] rtc/mc13xxx: Update driver to address y2038/y2106 issues
2015-01-13 15:44 [RFC PATCH v2 0/9] Provide y2038/y2106 safe rtc_class_ops.set_mmss64() Xunlei Pang
` (3 preceding siblings ...)
2015-01-13 15:44 ` [RFC PATCH v2 4/9] rtc/ab3100: " Xunlei Pang
@ 2015-01-13 15:44 ` Xunlei Pang
2015-01-14 15:07 ` Xunlei Pang
2015-01-13 15:44 ` [RFC PATCH v2 6/9] rtc/mxc: Modify rtc_update_alarm() not to touch the alarm time Xunlei Pang
` (3 subsequent siblings)
8 siblings, 1 reply; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
From: Xunlei Pang <pang.xunlei@linaro.org>
This driver has a number of y2038/y2106 issues.
This patch resolves them by:
- Replace rtc_time_to_tm() with rtc_time64_to_tm()
- Change mc13xxx_rtc_set_mmss() to use rtc_class_ops's set_mmss64()
After this patch, the driver should not have any remaining
y2038/y2106 issues.
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
drivers/rtc/rtc-mc13xxx.c | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
index 5bce904b..32df1d8 100644
--- a/drivers/rtc/rtc-mc13xxx.c
+++ b/drivers/rtc/rtc-mc13xxx.c
@@ -83,20 +83,19 @@ static int mc13xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
return ret;
} while (days1 != days2);
- rtc_time_to_tm(days1 * SEC_PER_DAY + seconds, tm);
+ rtc_time64_to_tm((time64_t)days1 * SEC_PER_DAY + seconds, tm);
return rtc_valid_tm(tm);
}
-static int mc13xxx_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int mc13xxx_rtc_set_mmss(struct device *dev, time64_t secs)
{
struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
unsigned int seconds, days;
unsigned int alarmseconds;
int ret;
- seconds = secs % SEC_PER_DAY;
- days = secs / SEC_PER_DAY;
+ days = div_s64_rem(secs, SEC_PER_DAY, &seconds);
mc13xxx_lock(priv->mc13xxx);
@@ -159,7 +158,7 @@ static int mc13xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
unsigned seconds, days;
- unsigned long s1970;
+ time64_t s1970;
int enabled, pending;
int ret;
@@ -189,10 +188,10 @@ out:
alarm->enabled = enabled;
alarm->pending = pending;
- s1970 = days * SEC_PER_DAY + seconds;
+ s1970 = (time64_t)days * SEC_PER_DAY + seconds;
- rtc_time_to_tm(s1970, &alarm->time);
- dev_dbg(dev, "%s: %lu\n", __func__, s1970);
+ rtc_time64_to_tm(s1970, &alarm->time);
+ dev_dbg(dev, "%s: %lld\n", __func__, (long long)s1970);
return 0;
}
@@ -200,8 +199,8 @@ out:
static int mc13xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
- unsigned long s1970;
- unsigned seconds, days;
+ time64_t s1970;
+ u32 seconds, days;
int ret;
mc13xxx_lock(priv->mc13xxx);
@@ -215,20 +214,17 @@ static int mc13xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
if (unlikely(ret))
goto out;
- ret = rtc_tm_to_time(&alarm->time, &s1970);
- if (unlikely(ret))
- goto out;
+ s1970 = rtc_tm_to_time64(&alarm->time);
- dev_dbg(dev, "%s: o%2.s %lu\n", __func__, alarm->enabled ? "n" : "ff",
- s1970);
+ dev_dbg(dev, "%s: o%2.s %lld\n", __func__, alarm->enabled ? "n" : "ff",
+ (long long)s1970);
ret = mc13xxx_rtc_irq_enable_unlocked(dev, alarm->enabled,
MC13XXX_IRQ_TODA);
if (unlikely(ret))
goto out;
- seconds = s1970 % SEC_PER_DAY;
- days = s1970 / SEC_PER_DAY;
+ days = div_s64_rem(s1970, SEC_PER_DAY, &seconds);
ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCDAYA, days);
if (unlikely(ret))
@@ -268,7 +264,7 @@ static irqreturn_t mc13xxx_rtc_update_handler(int irq, void *dev)
static const struct rtc_class_ops mc13xxx_rtc_ops = {
.read_time = mc13xxx_rtc_read_time,
- .set_mmss = mc13xxx_rtc_set_mmss,
+ .set_mmss64 = mc13xxx_rtc_set_mmss,
.read_alarm = mc13xxx_rtc_read_alarm,
.set_alarm = mc13xxx_rtc_set_alarm,
.alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable,
--
1.9.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [RFC PATCH v2 6/9] rtc/mxc: Modify rtc_update_alarm() not to touch the alarm time
2015-01-13 15:44 [RFC PATCH v2 0/9] Provide y2038/y2106 safe rtc_class_ops.set_mmss64() Xunlei Pang
` (4 preceding siblings ...)
2015-01-13 15:44 ` [RFC PATCH v2 5/9] rtc/mc13xxx: " Xunlei Pang
@ 2015-01-13 15:44 ` 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
` (2 subsequent siblings)
8 siblings, 2 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
From: Xunlei Pang <pang.xunlei@linaro.org>
rtc_class_ops's set_alarm() shouldn't deal with the alarm date,
as this is handled in the rtc core.
See rtc_dev_ioctl()'s RTC_ALM_SET and RTC_WKALM_SET cases.
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
drivers/rtc/rtc-mxc.c | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 3c3f8d1..a7b218f 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -173,29 +173,18 @@ static void set_alarm_or_time(struct device *dev, int time_alarm, u32 time)
* This function updates the RTC alarm registers and then clears all the
* interrupt status bits.
*/
-static int rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
+static void rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
{
- struct rtc_time alarm_tm, now_tm;
- unsigned long now, time;
+ unsigned long time;
struct platform_device *pdev = to_platform_device(dev);
struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
void __iomem *ioaddr = pdata->ioaddr;
- now = get_alarm_or_time(dev, MXC_RTC_TIME);
- rtc_time_to_tm(now, &now_tm);
- alarm_tm.tm_year = now_tm.tm_year;
- alarm_tm.tm_mon = now_tm.tm_mon;
- alarm_tm.tm_mday = now_tm.tm_mday;
- alarm_tm.tm_hour = alrm->tm_hour;
- alarm_tm.tm_min = alrm->tm_min;
- alarm_tm.tm_sec = alrm->tm_sec;
- rtc_tm_to_time(&alarm_tm, &time);
+ rtc_tm_to_time(alrm, &time);
/* clear all the interrupt status bits */
writew(readw(ioaddr + RTC_RTCISR), ioaddr + RTC_RTCISR);
set_alarm_or_time(dev, MXC_RTC_ALARM, time);
-
- return 0;
}
static void mxc_rtc_irq_enable(struct device *dev, unsigned int bit,
@@ -346,11 +335,8 @@ static int mxc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct platform_device *pdev = to_platform_device(dev);
struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
- int ret;
- ret = rtc_update_alarm(dev, &alrm->time);
- if (ret)
- return ret;
+ rtc_update_alarm(dev, &alrm->time);
memcpy(&pdata->g_rtc_alarm, &alrm->time, sizeof(struct rtc_time));
mxc_rtc_irq_enable(dev, RTC_ALM_BIT, alrm->enabled);
--
1.9.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [RFC PATCH v2 7/9] rtc/mxc: Convert get_alarm_or_time()/set_alarm_or_time() to use time64_t
2015-01-13 15:44 [RFC PATCH v2 0/9] Provide y2038/y2106 safe rtc_class_ops.set_mmss64() Xunlei Pang
` (5 preceding siblings ...)
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 15:44 ` 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
8 siblings, 0 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
From: Xunlei Pang <pang.xunlei@linaro.org>
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>
---
drivers/rtc/rtc-mxc.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index a7b218f..83cba23 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)
* This function is used to obtain the RTC time or the alarm value in
* second.
*/
-static u32 get_alarm_or_time(struct device *dev, int time_alarm)
+static time64_t get_alarm_or_time(struct device *dev, int time_alarm)
{
struct platform_device *pdev = to_platform_device(dev);
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)
hr = hr_min >> 8;
min = hr_min & 0xff;
- return (((day * 24 + hr) * 60) + min) * 60 + sec;
+ return ((((time64_t)day * 24 + hr) * 60) + min) * 60 + sec;
}
/*
* This function sets the RTC alarm value or the time value.
*/
-static void set_alarm_or_time(struct device *dev, int time_alarm, u32 time)
+static void set_alarm_or_time(struct device *dev, int time_alarm, time64_t time)
{
- u32 day, hr, min, sec, temp;
+ u32 tod, day, hr, min, sec, temp;
struct platform_device *pdev = to_platform_device(dev);
struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
void __iomem *ioaddr = pdata->ioaddr;
- day = time / 86400;
- time -= day * 86400;
+ day = div_s64_rem(time, 86400, &tod);
/* time is within a day now */
- hr = time / 3600;
- time -= hr * 3600;
+ hr = tod / 3600;
+ tod -= hr * 3600;
/* time is within an hour now */
- min = time / 60;
- sec = time - min * 60;
+ min = tod / 60;
+ sec = tod - min * 60;
temp = (hr << 8) + min;
@@ -175,12 +174,12 @@ static void set_alarm_or_time(struct device *dev, int time_alarm, u32 time)
*/
static void rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
{
- unsigned long time;
+ time64_t time;
struct platform_device *pdev = to_platform_device(dev);
struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
void __iomem *ioaddr = pdata->ioaddr;
- rtc_tm_to_time(alrm, &time);
+ time = rtc_tm_to_time64(alrm);
/* clear all the interrupt status bits */
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)
*/
static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
- u32 val;
+ time64_t val;
/* Avoid roll-over from reading the different registers */
do {
val = get_alarm_or_time(dev, MXC_RTC_TIME);
} while (val != get_alarm_or_time(dev, MXC_RTC_TIME));
- rtc_time_to_tm(val, tm);
+ rtc_time64_to_tm(val, tm);
return 0;
}
@@ -322,7 +321,7 @@ static int mxc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
void __iomem *ioaddr = pdata->ioaddr;
- rtc_time_to_tm(get_alarm_or_time(dev, MXC_RTC_ALARM), &alrm->time);
+ rtc_time64_to_tm(get_alarm_or_time(dev, MXC_RTC_ALARM), &alrm->time);
alrm->pending = ((readw(ioaddr + RTC_RTCISR) & RTC_ALM_BIT)) ? 1 : 0;
return 0;
--
1.9.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [RFC PATCH v2 8/9] rtc/mxc: Update driver to address y2038/y2106 issues
2015-01-13 15:44 [RFC PATCH v2 0/9] Provide y2038/y2106 safe rtc_class_ops.set_mmss64() Xunlei Pang
` (6 preceding siblings ...)
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 ` Xunlei Pang
2015-01-13 15:44 ` [RFC PATCH v2 9/9] alpha: change to use rtc_class_ops's set_mmss64() Xunlei Pang
8 siblings, 0 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
From: Xunlei Pang <pang.xunlei@linaro.org>
This driver has a number of y2038/y2106 issues.
This patch resolves them by:
- Replace rtc_time_to_tm() with rtc_time64_to_tm()
- Replace rtc_tm_to_time() with rtc_tm_to_time64()
- Change mxc_rtc_set_mmss() to use rtc_class_ops's set_mmss64()
After this patch, the driver should not have any remaining
y2038/y2106 issues.
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
drivers/rtc/rtc-mxc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 83cba23..09d422b 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -286,7 +286,7 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
/*
* This function sets the internal RTC time based on tm in Gregorian date.
*/
-static int mxc_rtc_set_mmss(struct device *dev, unsigned long time)
+static int mxc_rtc_set_mmss(struct device *dev, time64_t time)
{
struct platform_device *pdev = to_platform_device(dev);
struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
@@ -297,9 +297,9 @@ static int mxc_rtc_set_mmss(struct device *dev, unsigned long time)
if (is_imx1_rtc(pdata)) {
struct rtc_time tm;
- rtc_time_to_tm(time, &tm);
+ rtc_time64_to_tm(time, &tm);
tm.tm_year = 70;
- rtc_tm_to_time(&tm, &time);
+ time = rtc_tm_to_time64(&tm);
}
/* Avoid roll-over from reading the different registers */
@@ -347,7 +347,7 @@ static int mxc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
static struct rtc_class_ops mxc_rtc_ops = {
.release = mxc_rtc_release,
.read_time = mxc_rtc_read_time,
- .set_mmss = mxc_rtc_set_mmss,
+ .set_mmss64 = mxc_rtc_set_mmss,
.read_alarm = mxc_rtc_read_alarm,
.set_alarm = mxc_rtc_set_alarm,
.alarm_irq_enable = mxc_rtc_alarm_irq_enable,
--
1.9.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [RFC PATCH v2 9/9] alpha: change to use rtc_class_ops's set_mmss64()
2015-01-13 15:44 [RFC PATCH v2 0/9] Provide y2038/y2106 safe rtc_class_ops.set_mmss64() Xunlei Pang
` (7 preceding siblings ...)
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 ` Xunlei Pang
8 siblings, 0 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-13 15:44 UTC (permalink / raw)
To: linux-kernel, John Stultz, Arnd Bergmann
Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, Xunlei Pang
From: Xunlei Pang <pang.xunlei@linaro.org>
Change alpha_rtc_set_mmss() and remote_set_mmss() to use
rtc_class_ops's set_mmss64().
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
arch/alpha/kernel/rtc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/alpha/kernel/rtc.c b/arch/alpha/kernel/rtc.c
index c8d284d..f535a3f 100644
--- a/arch/alpha/kernel/rtc.c
+++ b/arch/alpha/kernel/rtc.c
@@ -116,7 +116,7 @@ alpha_rtc_set_time(struct device *dev, struct rtc_time *tm)
}
static int
-alpha_rtc_set_mmss(struct device *dev, unsigned long nowtime)
+alpha_rtc_set_mmss(struct device *dev, time64_t nowtime)
{
int retval = 0;
int real_seconds, real_minutes, cmos_minutes;
@@ -211,7 +211,7 @@ alpha_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
static const struct rtc_class_ops alpha_rtc_ops = {
.read_time = alpha_rtc_read_time,
.set_time = alpha_rtc_set_time,
- .set_mmss = alpha_rtc_set_mmss,
+ .set_mmss64 = alpha_rtc_set_mmss,
.ioctl = alpha_rtc_ioctl,
};
@@ -276,7 +276,7 @@ do_remote_mmss(void *data)
}
static int
-remote_set_mmss(struct device *dev, unsigned long now)
+remote_set_mmss(struct device *dev, time64_t now)
{
union remote_data x;
if (smp_processor_id() != boot_cpuid) {
@@ -290,7 +290,7 @@ remote_set_mmss(struct device *dev, unsigned long now)
static const struct rtc_class_ops remote_rtc_ops = {
.read_time = remote_read_time,
.set_time = remote_set_time,
- .set_mmss = remote_set_mmss,
+ .set_mmss64 = remote_set_mmss,
.ioctl = alpha_rtc_ioctl,
};
#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement
2015-01-13 15:44 ` [RFC PATCH v2 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement Xunlei Pang
@ 2015-01-13 16:12 ` Alessandro Zummo
0 siblings, 0 replies; 27+ messages in thread
From: Alessandro Zummo @ 2015-01-13 16:12 UTC (permalink / raw)
To: Xunlei Pang
Cc: linux-kernel, John Stultz, Arnd Bergmann, rtc-linux,
Thomas Gleixner, Xunlei Pang
On Tue, 13 Jan 2015 23:44:49 +0800
Xunlei Pang <xlpang@126.com> wrote:
> + else if (rtc->ops->set_mmss64) {
> + ;
> +
> + secs64 = rtc_tm_to_time64(tm);
time64_t secs64 = rtc_tm_to_time64(tm);
would do as well. add spaces, variables
and empty lines only when required for readability.
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
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
1 sibling, 1 reply; 27+ messages in thread
From: Alessandro Zummo @ 2015-01-13 16:17 UTC (permalink / raw)
To: Xunlei Pang
Cc: linux-kernel, John Stultz, Arnd Bergmann, rtc-linux,
Thomas Gleixner, Xunlei Pang
On Tue, 13 Jan 2015 23:44:50 +0800
Xunlei Pang <xlpang@126.com> wrote:
> -EXPORT_SYMBOL(get_seconds);
> +EXPORT_SYMBOL(get_seconds64);
Please leave get_seconds untouched
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues
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
0 siblings, 1 reply; 27+ messages in thread
From: Alessandro Zummo @ 2015-01-13 16:19 UTC (permalink / raw)
To: Xunlei Pang
Cc: linux-kernel, John Stultz, Arnd Bergmann, rtc-linux,
Thomas Gleixner, Xunlei Pang
On Tue, 13 Jan 2015 23:44:51 +0800
Xunlei Pang <xlpang@126.com> wrote:
> This patch resolves them by:
> - Repalce get_seconds() with get_seconds64()
> - Replace rtc_time_to_tm() with rtc_time64_to_tm()
> - Change test_rtc_set_mmss() to use rtc_class_ops's set_mmss64()
so we no more have a non time64 test driver?
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 4/9] rtc/ab3100: Update driver to address y2038/y2106 issues
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
1 sibling, 0 replies; 27+ messages in thread
From: Alessandro Zummo @ 2015-01-13 16:20 UTC (permalink / raw)
To: Xunlei Pang
Cc: linux-kernel, John Stultz, Arnd Bergmann, rtc-linux,
Thomas Gleixner, Xunlei Pang, Linus Walleij
On Tue, 13 Jan 2015 23:44:52 +0800
Xunlei Pang <xlpang@126.com> wrote:
> From: Xunlei Pang <pang.xunlei@linaro.org>
>
> This driver has a number of y2038/y2106 issues.
This should probably be evaluated by
Linus Walleij <linus.walleij@stericsson.com>
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 6/9] rtc/mxc: Modify rtc_update_alarm() not to touch the alarm time
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
1 sibling, 0 replies; 27+ messages in thread
From: Alessandro Zummo @ 2015-01-13 16:23 UTC (permalink / raw)
To: Xunlei Pang
Cc: linux-kernel, John Stultz, Arnd Bergmann, rtc-linux,
Thomas Gleixner, Xunlei Pang
On Tue, 13 Jan 2015 23:44:54 +0800
Xunlei Pang <xlpang@126.com> wrote:
> rtc_class_ops's set_alarm() shouldn't deal with the alarm date,
> as this is handled in the rtc core.
Please CC the author and ask him. The same applies for the other drivers.
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
2015-01-13 16:17 ` Alessandro Zummo
@ 2015-01-13 20:34 ` Arnd Bergmann
0 siblings, 0 replies; 27+ messages in thread
From: Arnd Bergmann @ 2015-01-13 20:34 UTC (permalink / raw)
To: Alessandro Zummo
Cc: Xunlei Pang, linux-kernel, John Stultz, Arnd Bergmann, rtc-linux,
Thomas Gleixner, Xunlei Pang
On Tuesday 13 January 2015 17:17:44 Alessandro Zummo wrote:
> On Tue, 13 Jan 2015 23:44:50 +0800
> Xunlei Pang <xlpang@126.com> wrote:
>
> > -EXPORT_SYMBOL(get_seconds);
> > +EXPORT_SYMBOL(get_seconds64);
>
> Please leave get_seconds untouched
>
The patch leaves it in place. However, we already have ktime_get_seconds()
and ktime_get_real_seconds(). Code that currently uses get_seconds can
trivially be converted to the latter.
Arnd
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
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:42 ` Thomas Gleixner
2015-01-14 14:52 ` Xunlei Pang
1 sibling, 1 reply; 27+ messages in thread
From: Thomas Gleixner @ 2015-01-13 20:42 UTC (permalink / raw)
To: Xunlei Pang
Cc: linux-kernel, John Stultz, Arnd Bergmann, rtc-linux,
Alessandro Zummo, Xunlei Pang
On Tue, 13 Jan 2015, Xunlei Pang wrote:
> From: Xunlei Pang <pang.xunlei@linaro.org>
>
> As part of addressing "y2038 problem" for in-kernel uses, this
> patch adds safe get_seconds64() using time64_t.
>
> After this patch, get_seconds() is deprecated and all its call sites
> will be fixed using get_seconds64(), after that it can be removed.
Why another interface?
We already have ktime_get_real_seconds(). That handles 32bit
correctly, while your new function does not.
You cannot return a 64bit value unprotected against updates on 32bit,
unless you want to implement a RNG.
Thanks,
tglx
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
2015-01-13 20:42 ` Thomas Gleixner
@ 2015-01-14 14:52 ` Xunlei Pang
0 siblings, 0 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-14 14:52 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Xunlei Pang, lkml, John Stultz, Arnd Bergmann,
rtc-linux@googlegroups.com, Alessandro Zummo
On 14 January 2015 at 04:42, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Tue, 13 Jan 2015, Xunlei Pang wrote:
>
>> From: Xunlei Pang <pang.xunlei@linaro.org>
>>
>> As part of addressing "y2038 problem" for in-kernel uses, this
>> patch adds safe get_seconds64() using time64_t.
>>
>> After this patch, get_seconds() is deprecated and all its call sites
>> will be fixed using get_seconds64(), after that it can be removed.
>
> Why another interface?
>
> We already have ktime_get_real_seconds(). That handles 32bit
> correctly, while your new function does not.
>
> You cannot return a 64bit value unprotected against updates on 32bit,
> unless you want to implement a RNG.
Yes, ktime_get_real_seconds() should be used instead.
Thanks,
Xunlei
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues
2015-01-13 16:19 ` Alessandro Zummo
@ 2015-01-14 14:56 ` Xunlei Pang
2015-01-14 15:03 ` Alessandro Zummo
0 siblings, 1 reply; 27+ messages in thread
From: Xunlei Pang @ 2015-01-14 14:56 UTC (permalink / raw)
To: Alessandro Zummo
Cc: Xunlei Pang, lkml, John Stultz, Arnd Bergmann,
rtc-linux@googlegroups.com, Thomas Gleixner
On 14 January 2015 at 00:19, Alessandro Zummo <a.zummo@towertech.it> wrote:
> On Tue, 13 Jan 2015 23:44:51 +0800
> Xunlei Pang <xlpang@126.com> wrote:
>
>> This patch resolves them by:
>> - Repalce get_seconds() with get_seconds64()
>> - Replace rtc_time_to_tm() with rtc_time64_to_tm()
>> - Change test_rtc_set_mmss() to use rtc_class_ops's set_mmss64()
>
> so we no more have a non time64 test driver?|
Hi Alessandro,
We want to do away with set_mmss() eventually, time64 is the final version,
so I think this would be ok.
Thanks,
Xunlei
>
> --
>
> Best regards,
>
> Alessandro Zummo,
> Tower Technologies - Torino, Italy
>
> http://www.towertech.it
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues
2015-01-14 14:56 ` Xunlei Pang
@ 2015-01-14 15:03 ` Alessandro Zummo
2015-01-14 15:26 ` Xunlei Pang
0 siblings, 1 reply; 27+ messages in thread
From: Alessandro Zummo @ 2015-01-14 15:03 UTC (permalink / raw)
To: Xunlei Pang
Cc: Xunlei Pang, lkml, John Stultz, Arnd Bergmann,
rtc-linux@googlegroups.com, Thomas Gleixner
On Wed, 14 Jan 2015 22:56:15 +0800
Xunlei Pang <pang.xunlei@linaro.org> wrote:
> We want to do away with set_mmss() eventually, time64 is the final version,
> so I think this would be ok.
We'll get rid of set_mmss() from the test driver later on,
after everything else has been converted :)
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 5/9] rtc/mc13xxx: Update driver to address y2038/y2106 issues
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
0 siblings, 1 reply; 27+ messages in thread
From: Xunlei Pang @ 2015-01-14 15:07 UTC (permalink / raw)
To: Xunlei Pang
Cc: lkml, John Stultz, Arnd Bergmann, rtc-linux@googlegroups.com,
Thomas Gleixner, Alessandro Zummo, Uwe Kleine-Koenig
Cc Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
On 13 January 2015 at 23:44, Xunlei Pang <xlpang@126.com> wrote:
> From: Xunlei Pang <pang.xunlei@linaro.org>
>
> This driver has a number of y2038/y2106 issues.
>
> This patch resolves them by:
> - Replace rtc_time_to_tm() with rtc_time64_to_tm()
> - Change mc13xxx_rtc_set_mmss() to use rtc_class_ops's set_mmss64()
>
> After this patch, the driver should not have any remaining
> y2038/y2106 issues.
>
> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
> ---
> drivers/rtc/rtc-mc13xxx.c | 32 ++++++++++++++------------------
> 1 file changed, 14 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
> index 5bce904b..32df1d8 100644
> --- a/drivers/rtc/rtc-mc13xxx.c
> +++ b/drivers/rtc/rtc-mc13xxx.c
> @@ -83,20 +83,19 @@ static int mc13xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
> return ret;
> } while (days1 != days2);
>
> - rtc_time_to_tm(days1 * SEC_PER_DAY + seconds, tm);
> + rtc_time64_to_tm((time64_t)days1 * SEC_PER_DAY + seconds, tm);
>
> return rtc_valid_tm(tm);
> }
>
> -static int mc13xxx_rtc_set_mmss(struct device *dev, unsigned long secs)
> +static int mc13xxx_rtc_set_mmss(struct device *dev, time64_t secs)
> {
> struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
> unsigned int seconds, days;
> unsigned int alarmseconds;
> int ret;
>
> - seconds = secs % SEC_PER_DAY;
> - days = secs / SEC_PER_DAY;
> + days = div_s64_rem(secs, SEC_PER_DAY, &seconds);
>
> mc13xxx_lock(priv->mc13xxx);
>
> @@ -159,7 +158,7 @@ static int mc13xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
> {
> struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
> unsigned seconds, days;
> - unsigned long s1970;
> + time64_t s1970;
> int enabled, pending;
> int ret;
>
> @@ -189,10 +188,10 @@ out:
> alarm->enabled = enabled;
> alarm->pending = pending;
>
> - s1970 = days * SEC_PER_DAY + seconds;
> + s1970 = (time64_t)days * SEC_PER_DAY + seconds;
>
> - rtc_time_to_tm(s1970, &alarm->time);
> - dev_dbg(dev, "%s: %lu\n", __func__, s1970);
> + rtc_time64_to_tm(s1970, &alarm->time);
> + dev_dbg(dev, "%s: %lld\n", __func__, (long long)s1970);
>
> return 0;
> }
> @@ -200,8 +199,8 @@ out:
> static int mc13xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
> {
> struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
> - unsigned long s1970;
> - unsigned seconds, days;
> + time64_t s1970;
> + u32 seconds, days;
> int ret;
>
> mc13xxx_lock(priv->mc13xxx);
> @@ -215,20 +214,17 @@ static int mc13xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
> if (unlikely(ret))
> goto out;
>
> - ret = rtc_tm_to_time(&alarm->time, &s1970);
> - if (unlikely(ret))
> - goto out;
> + s1970 = rtc_tm_to_time64(&alarm->time);
>
> - dev_dbg(dev, "%s: o%2.s %lu\n", __func__, alarm->enabled ? "n" : "ff",
> - s1970);
> + dev_dbg(dev, "%s: o%2.s %lld\n", __func__, alarm->enabled ? "n" : "ff",
> + (long long)s1970);
>
> ret = mc13xxx_rtc_irq_enable_unlocked(dev, alarm->enabled,
> MC13XXX_IRQ_TODA);
> if (unlikely(ret))
> goto out;
>
> - seconds = s1970 % SEC_PER_DAY;
> - days = s1970 / SEC_PER_DAY;
> + days = div_s64_rem(s1970, SEC_PER_DAY, &seconds);
>
> ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCDAYA, days);
> if (unlikely(ret))
> @@ -268,7 +264,7 @@ static irqreturn_t mc13xxx_rtc_update_handler(int irq, void *dev)
>
> static const struct rtc_class_ops mc13xxx_rtc_ops = {
> .read_time = mc13xxx_rtc_read_time,
> - .set_mmss = mc13xxx_rtc_set_mmss,
> + .set_mmss64 = mc13xxx_rtc_set_mmss,
> .read_alarm = mc13xxx_rtc_read_alarm,
> .set_alarm = mc13xxx_rtc_set_alarm,
> .alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable,
> --
> 1.9.1
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 6/9] rtc/mxc: Modify rtc_update_alarm() not to touch the alarm time
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
1 sibling, 0 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-14 15:13 UTC (permalink / raw)
To: Xunlei Pang
Cc: lkml, John Stultz, Arnd Bergmann, rtc-linux@googlegroups.com,
Thomas Gleixner, Alessandro Zummo, Fabio Estevam
Cc Fabio Estevam <fabio.estevam@freescale.com>
On 13 January 2015 at 23:44, Xunlei Pang <xlpang@126.com> wrote:
> From: Xunlei Pang <pang.xunlei@linaro.org>
>
> rtc_class_ops's set_alarm() shouldn't deal with the alarm date,
> as this is handled in the rtc core.
>
> See rtc_dev_ioctl()'s RTC_ALM_SET and RTC_WKALM_SET cases.
>
> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
> ---
> drivers/rtc/rtc-mxc.c | 22 ++++------------------
> 1 file changed, 4 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
> index 3c3f8d1..a7b218f 100644
> --- a/drivers/rtc/rtc-mxc.c
> +++ b/drivers/rtc/rtc-mxc.c
> @@ -173,29 +173,18 @@ static void set_alarm_or_time(struct device *dev, int time_alarm, u32 time)
> * This function updates the RTC alarm registers and then clears all the
> * interrupt status bits.
> */
> -static int rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
> +static void rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
> {
> - struct rtc_time alarm_tm, now_tm;
> - unsigned long now, time;
> + unsigned long time;
> struct platform_device *pdev = to_platform_device(dev);
> struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
> void __iomem *ioaddr = pdata->ioaddr;
>
> - now = get_alarm_or_time(dev, MXC_RTC_TIME);
> - rtc_time_to_tm(now, &now_tm);
> - alarm_tm.tm_year = now_tm.tm_year;
> - alarm_tm.tm_mon = now_tm.tm_mon;
> - alarm_tm.tm_mday = now_tm.tm_mday;
> - alarm_tm.tm_hour = alrm->tm_hour;
> - alarm_tm.tm_min = alrm->tm_min;
> - alarm_tm.tm_sec = alrm->tm_sec;
> - rtc_tm_to_time(&alarm_tm, &time);
> + rtc_tm_to_time(alrm, &time);
>
> /* clear all the interrupt status bits */
> writew(readw(ioaddr + RTC_RTCISR), ioaddr + RTC_RTCISR);
> set_alarm_or_time(dev, MXC_RTC_ALARM, time);
> -
> - return 0;
> }
>
> static void mxc_rtc_irq_enable(struct device *dev, unsigned int bit,
> @@ -346,11 +335,8 @@ static int mxc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
> - int ret;
>
> - ret = rtc_update_alarm(dev, &alrm->time);
> - if (ret)
> - return ret;
> + rtc_update_alarm(dev, &alrm->time);
>
> memcpy(&pdata->g_rtc_alarm, &alrm->time, sizeof(struct rtc_time));
> mxc_rtc_irq_enable(dev, RTC_ALM_BIT, alrm->enabled);
> --
> 1.9.1
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues
2015-01-14 15:03 ` Alessandro Zummo
@ 2015-01-14 15:26 ` Xunlei Pang
2015-01-14 15:39 ` Alessandro Zummo
0 siblings, 1 reply; 27+ messages in thread
From: Xunlei Pang @ 2015-01-14 15:26 UTC (permalink / raw)
To: Alessandro Zummo
Cc: Xunlei Pang, lkml, John Stultz, Arnd Bergmann,
rtc-linux@googlegroups.com, Thomas Gleixner
On 14 January 2015 at 23:03, Alessandro Zummo <a.zummo@towertech.it> wrote:
> On Wed, 14 Jan 2015 22:56:15 +0800
> Xunlei Pang <pang.xunlei@linaro.org> wrote:
>
>> We want to do away with set_mmss() eventually, time64 is the final version,
>> so I think this would be ok.
>
> We'll get rid of set_mmss() from the test driver later on,
> after everything else has been converted :)
Ok.
But on the other hand, we will have no test for set_mmss64(),
because adding the set_mmss64() will make set_mmss() dysfunctional.
Thanks,
Xunlei
>
> --
>
> Best regards,
>
> Alessandro Zummo,
> Tower Technologies - Torino, Italy
>
> http://www.towertech.it
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues
2015-01-14 15:26 ` Xunlei Pang
@ 2015-01-14 15:39 ` Alessandro Zummo
2015-01-16 15:40 ` Xunlei Pang
0 siblings, 1 reply; 27+ messages in thread
From: Alessandro Zummo @ 2015-01-14 15:39 UTC (permalink / raw)
To: Xunlei Pang
Cc: Xunlei Pang, lkml, John Stultz, Arnd Bergmann,
rtc-linux@googlegroups.com, Thomas Gleixner
On Wed, 14 Jan 2015 23:26:37 +0800
Xunlei Pang <pang.xunlei@linaro.org> wrote:
> But on the other hand, we will have no test for set_mmss64(),
> because adding the set_mmss64() will make set_mmss() dysfunctional.
add a module parameter
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 5/9] rtc/mc13xxx: Update driver to address y2038/y2106 issues
2015-01-14 15:07 ` Xunlei Pang
@ 2015-01-14 17:03 ` Uwe Kleine-König
0 siblings, 0 replies; 27+ messages in thread
From: Uwe Kleine-König @ 2015-01-14 17:03 UTC (permalink / raw)
To: Xunlei Pang
Cc: Xunlei Pang, lkml, John Stultz, Arnd Bergmann,
rtc-linux@googlegroups.com, Thomas Gleixner, Alessandro Zummo
Hello,
On Wed, Jan 14, 2015 at 11:07:31PM +0800, Xunlei Pang wrote:
> Cc Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Thanks, that was useful.
>
> On 13 January 2015 at 23:44, Xunlei Pang <xlpang@126.com> wrote:
> > From: Xunlei Pang <pang.xunlei@linaro.org>
> >
> > This driver has a number of y2038/y2106 issues.
> >
> > This patch resolves them by:
> > - Replace rtc_time_to_tm() with rtc_time64_to_tm()
> > - Change mc13xxx_rtc_set_mmss() to use rtc_class_ops's set_mmss64()
> >
> > After this patch, the driver should not have any remaining
> > y2038/y2106 issues.
> >
> > Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
> > ---
> > drivers/rtc/rtc-mc13xxx.c | 32 ++++++++++++++------------------
> > 1 file changed, 14 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
> > index 5bce904b..32df1d8 100644
> > --- a/drivers/rtc/rtc-mc13xxx.c
> > +++ b/drivers/rtc/rtc-mc13xxx.c
> > @@ -83,20 +83,19 @@ static int mc13xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
> > return ret;
> > } while (days1 != days2);
> >
> > - rtc_time_to_tm(days1 * SEC_PER_DAY + seconds, tm);
> > + rtc_time64_to_tm((time64_t)days1 * SEC_PER_DAY + seconds, tm);
> >
> > return rtc_valid_tm(tm);
> > }
> >
> > -static int mc13xxx_rtc_set_mmss(struct device *dev, unsigned long secs)
> > +static int mc13xxx_rtc_set_mmss(struct device *dev, time64_t secs)
I don't know if there is a usual conversion rule, but I'd expect that
the function is also renamed to get a suffix 64.
Other than that the patch looks good.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 4/9] rtc/ab3100: Update driver to address y2038/y2106 issues
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
1 sibling, 0 replies; 27+ messages in thread
From: Linus Walleij @ 2015-01-15 17:23 UTC (permalink / raw)
To: Xunlei Pang
Cc: linux-kernel@vger.kernel.org, John Stultz, Arnd Bergmann,
rtc-linux@googlegroups.com, Thomas Gleixner, Alessandro Zummo,
Xunlei Pang
On Tue, Jan 13, 2015 at 4:44 PM, Xunlei Pang <xlpang@126.com> wrote:
> From: Xunlei Pang <pang.xunlei@linaro.org>
>
> This driver has a number of y2038/y2106 issues.
>
> This patch resolves them by:
> - Replace rtc_tm_to_time() with rtc_tm_to_time64()
> - Replace rtc_time_to_tm() with rtc_time64_to_tm()
> - Change ab3100_rtc_set_mmss() to use rtc_class_ops's set_mmss64()
>
> After this patch, the driver should not have any remaining
> y2038/y2106 issues.
>
> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH v2 3/9] rtc/test: Update driver to address y2038/y2106 issues
2015-01-14 15:39 ` Alessandro Zummo
@ 2015-01-16 15:40 ` Xunlei Pang
0 siblings, 0 replies; 27+ messages in thread
From: Xunlei Pang @ 2015-01-16 15:40 UTC (permalink / raw)
To: Alessandro Zummo
Cc: Xunlei Pang, lkml, John Stultz, Arnd Bergmann,
rtc-linux@googlegroups.com, Thomas Gleixner
On 14 January 2015 at 23:39, Alessandro Zummo <a.zummo@towertech.it> wrote:
> On Wed, 14 Jan 2015 23:26:37 +0800
> Xunlei Pang <pang.xunlei@linaro.org> wrote:
>
>> But on the other hand, we will have no test for set_mmss64(),
>> because adding the set_mmss64() will make set_mmss() dysfunctional.
>
> add a module parameter
Hi Alessandro,
Thanks for your advice, how about the following one?
---
drivers/rtc/rtc-test.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index 8f86fa9..3a2da4c 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -13,6 +13,10 @@
#include <linux/rtc.h>
#include <linux/platform_device.h>
+static int test_mmss64;
+module_param(test_mmss64, int, 0644);
+MODULE_PARM_DESC(test_mmss64, "Test struct rtc_class_ops.set_mmss64().");
+
static struct platform_device *test0 = NULL, *test1 = NULL;
static int test_rtc_read_alarm(struct device *dev,
@@ -30,7 +34,13 @@ static int test_rtc_set_alarm(struct device *dev,
static int test_rtc_read_time(struct device *dev,
struct rtc_time *tm)
{
- rtc_time_to_tm(get_seconds(), tm);
+ rtc_time64_to_tm(ktime_get_real_seconds(), tm);
+ return 0;
+}
+
+static int test_rtc_set_mmss64(struct device *dev, time64_t secs)
+{
+ dev_info(dev, "%s, secs = %lld\n", __func__, (long long)secs);
return 0;
}
@@ -55,7 +65,7 @@ static int test_rtc_alarm_irq_enable(struct device
*dev, unsigned int enable)
return 0;
}
-static const struct rtc_class_ops test_rtc_ops = {
+static struct rtc_class_ops test_rtc_ops = {
.proc = test_rtc_proc,
.read_time = test_rtc_read_time,
.read_alarm = test_rtc_read_alarm,
@@ -101,6 +111,11 @@ static int test_probe(struct platform_device *plat_dev)
int err;
struct rtc_device *rtc;
+ if (test_mmss64) {
+ test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
+ test_rtc_ops.set_mmss = NULL;
+ }
+
rtc = devm_rtc_device_register(&plat_dev->dev, "test",
&test_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
^ permalink raw reply related [flat|nested] 27+ messages in thread
end of thread, other threads:[~2015-01-16 15:40 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [RFC PATCH v2 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement Xunlei Pang
2015-01-13 16:12 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox