rtc_time_to_tm() and rtc_tm_to_time() are using 32 bits variables so they may break in y2038/2106.
This patcheset is a subset (22 vs 51) of the first version where I have only updated the drivers where I believe using 64 bits functions could help. For example hardwares using BCD like time encoding or those storing date in more than 32 bits are in this series.
I have rebase my patches on top of rtc-next and fix the errors reported by Kbuild.
Benjamin Gaignard (22): x86: rtc: stop using rtc deprecated functions x86: intel-mid: vrtc: stop using rtc deprecated functions net: broadcom: stop using rtc deprecated functions rtc: ab-b5ze-s3: stop using rtc deprecated functions rtc: ab8500: stop using rtc deprecated functions rtc: cpcap: stop using rtc deprecated functions rtc: davinci: stop using rtc deprecated functions rtc: ds1305: stop using rtc deprecated functions rtc: ds1511: stop using rtc deprecated functions rtc: ds1553: stop using rtc deprecated functions rtc: gemini: stop using rtc deprecated functions rtc: mv: stop using rtc deprecated functions rtc: omap: stop using rtc deprecated functions rtc: pcap: stop using rtc deprecated functions rtc: rs5c348: stop using rtc deprecated functions rtc: sh: stop using rtc deprecated functions rtc: snvs: stop using rtc deprecated functions rtc: stk17ta8: stop using rtc deprecated functions rtc: sun6i: stop using rtc deprecated functions rtc: sysfs: stop using rtc deprecated functions rtc: test: stop using rtc deprecated functions power: suspend test: stop using rtc deprecated functions
arch/x86/kernel/rtc.c | 6 ++-- arch/x86/platform/intel-mid/intel_mid_vrtc.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/rtc/rtc-ab-b5ze-s3.c | 45 +++++++---------------- drivers/rtc/rtc-ab8500.c | 53 +++++++++++++--------------- drivers/rtc/rtc-cpcap.c | 17 +++++---- drivers/rtc/rtc-davinci.c | 8 ++--- drivers/rtc/rtc-ds1305.c | 11 +++--- drivers/rtc/rtc-ds1511.c | 2 +- drivers/rtc/rtc-ds1553.c | 2 +- drivers/rtc/rtc-ftrtc010.c | 8 ++--- drivers/rtc/rtc-mv.c | 2 +- drivers/rtc/rtc-omap.c | 6 ++-- drivers/rtc/rtc-pcap.c | 28 +++++++-------- drivers/rtc/rtc-rs5c348.c | 4 +-- drivers/rtc/rtc-sh.c | 2 +- drivers/rtc/rtc-snvs.c | 14 ++++---- drivers/rtc/rtc-stk17ta8.c | 2 +- drivers/rtc/rtc-sun6i.c | 14 ++++---- drivers/rtc/rtc-sysfs.c | 25 ++++++------- drivers/rtc/rtc-test.c | 17 +-------- kernel/power/suspend_test.c | 6 ++-- 22 files changed, 116 insertions(+), 160 deletions(-)
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Thomas Gleixner tglx@linutronix.de CC: Ingo Molnar mingo@redhat.com CC: x86@kernel.org CC: John Stultz john.stultz@linaro.org CC: linux-kernel@vger.kernel.org --- arch/x86/kernel/rtc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index 5b21cb7..76b817c 100644 --- a/arch/x86/kernel/rtc.c +++ b/arch/x86/kernel/rtc.c @@ -40,11 +40,11 @@ */ int mach_set_rtc_mmss(const struct timespec *now) { - unsigned long nowtime = now->tv_sec; + unsigned long long nowtime = now->tv_sec; struct rtc_time tm; int retval = 0;
- rtc_time_to_tm(nowtime, &tm); + rtc_time64_to_tm(nowtime, &tm); if (!rtc_valid_tm(&tm)) { retval = mc146818_set_time(&tm); if (retval) @@ -52,7 +52,7 @@ int mach_set_rtc_mmss(const struct timespec *now) __func__, retval); } else { printk(KERN_ERR - "%s: Invalid RTC value: write of %lx to RTC failed\n", + "%s: Invalid RTC value: write of %llx to RTC failed\n", __func__, nowtime); retval = -EINVAL; }
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Thomas Gleixner tglx@linutronix.de CC: Ingo Molnar mingo@redhat.com CC: x86@kernel.org CC: linux-kernel@vger.kernel.org --- arch/x86/platform/intel-mid/intel_mid_vrtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/platform/intel-mid/intel_mid_vrtc.c b/arch/x86/platform/intel-mid/intel_mid_vrtc.c index 5802486..a177081 100644 --- a/arch/x86/platform/intel-mid/intel_mid_vrtc.c +++ b/arch/x86/platform/intel-mid/intel_mid_vrtc.c @@ -94,7 +94,7 @@ int vrtc_set_mmss(const struct timespec *now) int year; int retval = 0;
- rtc_time_to_tm(now->tv_sec, &tm); + rtc_time64_to_tm(now->tv_sec, &tm); if (!rtc_valid_tm(&tm) && tm.tm_year >= 72) { /* * tm.year is the number of years since 1900, and the
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Michael Chan michael.chan@broadcom.com CC: netdev@vger.kernel.org CC: linux-kernel@vger.kernel.org --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b56c54d..9fef202 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4703,7 +4703,7 @@ int bnxt_hwrm_fw_set_time(struct bnxt *bp) return -EOPNOTSUPP;
do_gettimeofday(&tv); - rtc_time_to_tm(tv.tv_sec, &tm); + rtc_time64_to_tm(tv.tv_sec, &tm); bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_SET_TIME, -1, -1); req.year = cpu_to_le16(1900 + tm.tm_year); req.month = 1 + tm.tm_mon;
On Wed, Jul 12, 2017 at 1:04 AM, Benjamin Gaignard benjamin.gaignard@linaro.org wrote:
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Michael Chan michael.chan@broadcom.com CC: netdev@vger.kernel.org CC: linux-kernel@vger.kernel.org
Acked-by: Michael Chan michael.chan@broadcom.com
Thanks.
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-ab-b5ze-s3.c | 45 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-)
diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c index a319bf1..ce37997 100644 --- a/drivers/rtc/rtc-ab-b5ze-s3.c +++ b/drivers/rtc/rtc-ab-b5ze-s3.c @@ -328,7 +328,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev, struct abb5zes3_rtc_data *data = dev_get_drvdata(dev); struct rtc_time rtc_tm, *alarm_tm = &alarm->time; u8 regs[ABB5ZES3_TIMA_SEC_LEN + 1]; - unsigned long rtc_secs; + unsigned long long rtc_secs; unsigned int reg; u8 timer_secs; int ret; @@ -352,9 +352,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev, goto err;
/* ... convert to seconds ... */ - ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm);
/* ... add remaining timer A time ... */ ret = sec_from_timer_a(&timer_secs, regs[1], regs[2]); @@ -362,7 +360,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev, goto err;
/* ... and convert back. */ - rtc_time_to_tm(rtc_secs + timer_secs, alarm_tm); + rtc_time64_to_tm(rtc_secs + timer_secs, alarm_tm);
ret = regmap_read(data->regmap, ABB5ZES3_REG_CTRL2, ®); if (ret) { @@ -383,7 +381,7 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev, { struct abb5zes3_rtc_data *data = dev_get_drvdata(dev); struct rtc_time rtc_tm, *alarm_tm = &alarm->time; - unsigned long rtc_secs, alarm_secs; + unsigned long long rtc_secs, alarm_secs; u8 regs[ABB5ZES3_ALRM_SEC_LEN]; unsigned int reg; int ret; @@ -414,13 +412,8 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev, alarm_tm->tm_year = rtc_tm.tm_year; alarm_tm->tm_mon = rtc_tm.tm_mon;
- ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; - - ret = rtc_tm_to_time(alarm_tm, &alarm_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm); + alarm_secs = rtc_tm_to_time64(alarm_tm);
if (alarm_secs < rtc_secs) { if (alarm_tm->tm_mon == 11) { @@ -477,7 +470,7 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { struct abb5zes3_rtc_data *data = dev_get_drvdata(dev); struct rtc_time *alarm_tm = &alarm->time; - unsigned long rtc_secs, alarm_secs; + unsigned long long rtc_secs, alarm_secs; u8 regs[ABB5ZES3_ALRM_SEC_LEN]; struct rtc_time rtc_tm; int ret, enable = 1; @@ -486,13 +479,8 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) if (ret) goto err;
- ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; - - ret = rtc_tm_to_time(alarm_tm, &alarm_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm); + alarm_secs = rtc_tm_to_time64(alarm_tm);
/* If alarm time is before current time, disable the alarm */ if (!alarm->enabled || alarm_secs <= rtc_secs) { @@ -511,9 +499,7 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) rtc_tm.tm_mon += 1; }
- ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm);
if (alarm_secs > rtc_secs) { dev_err(dev, "%s: alarm maximum is one month in the " @@ -597,7 +583,7 @@ static int abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { struct abb5zes3_rtc_data *data = dev_get_drvdata(dev); struct rtc_time *alarm_tm = &alarm->time; - unsigned long rtc_secs, alarm_secs; + unsigned long long rtc_secs, alarm_secs; struct rtc_time rtc_tm; int ret;
@@ -606,13 +592,8 @@ static int abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) if (ret) goto err;
- ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; - - ret = rtc_tm_to_time(alarm_tm, &alarm_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm); + alarm_secs = rtc_tm_to_time64(alarm_tm);
/* Let's first disable both the alarm and the timer interrupts */ ret = _abb5zes3_rtc_update_alarm(dev, false);
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
version 2: - fix compilation issues by using do_div() Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org Acked-by: Linus Walleij linus.walleij@linaro.org CC: Linus Walleij linus.walleij@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org CC: linux-arm-kernel@lists.infradead.org --- drivers/rtc/rtc-ab8500.c | 53 +++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 28 deletions(-)
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c index 24a0af6..4b8696f 100644 --- a/drivers/rtc/rtc-ab8500.c +++ b/drivers/rtc/rtc-ab8500.c @@ -71,7 +71,7 @@ /* Calculate the seconds from 1970 to 01-01-2000 00:00:00 */ static unsigned long get_elapsed_seconds(int year) { - unsigned long secs; + unsigned long long secs; struct rtc_time tm = { .tm_year = year - 1900, .tm_mday = 1, @@ -81,7 +81,7 @@ static unsigned long get_elapsed_seconds(int year) * This function calculates secs from 1970 and not from * 1900, even if we supply the offset from year 1900. */ - rtc_tm_to_time(&tm, &secs); + secs = rtc_tm_to_time64(&tm); return secs; }
@@ -89,7 +89,7 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm) { unsigned long timeout = jiffies + HZ; int retval, i; - unsigned long mins, secs; + unsigned long long mins, secs; unsigned char buf[ARRAY_SIZE(ab8500_rtc_time_regs)]; u8 value;
@@ -130,7 +130,7 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm) /* Add back the initially subtracted number of seconds */ secs += get_elapsed_seconds(AB8500_RTC_EPOCH);
- rtc_time_to_tm(secs, tm); + rtc_time64_to_tm(secs, tm); return rtc_valid_tm(tm); }
@@ -138,7 +138,7 @@ static int ab8500_rtc_set_time(struct device *dev, struct rtc_time *tm) { int retval, i; unsigned char buf[ARRAY_SIZE(ab8500_rtc_time_regs)]; - unsigned long no_secs, no_mins, secs = 0; + unsigned long long no_secs, secs = 0;
if (tm->tm_year < (AB8500_RTC_EPOCH - 1900)) { dev_dbg(dev, "year should be equal to or greater than %d\n", @@ -147,7 +147,7 @@ static int ab8500_rtc_set_time(struct device *dev, struct rtc_time *tm) }
/* Get the number of seconds since 1970 */ - rtc_tm_to_time(tm, &secs); + secs = rtc_tm_to_time64(tm);
/* * Convert it to the number of seconds since 01-01-2000 00:00:00, since @@ -155,18 +155,16 @@ static int ab8500_rtc_set_time(struct device *dev, struct rtc_time *tm) */ secs -= get_elapsed_seconds(AB8500_RTC_EPOCH);
- no_mins = secs / 60; - - no_secs = secs % 60; + no_secs = do_div(secs, 60); /* Make the seconds count as per the RTC resolution */ no_secs = no_secs * COUNTS_PER_SEC;
buf[4] = no_secs & 0xFF; buf[3] = (no_secs >> 8) & 0xFF;
- buf[2] = no_mins & 0xFF; - buf[1] = (no_mins >> 8) & 0xFF; - buf[0] = (no_mins >> 16) & 0xFF; + buf[2] = secs & 0xFF; + buf[1] = (secs >> 8) & 0xFF; + buf[0] = (secs >> 16) & 0xFF;
for (i = 0; i < ARRAY_SIZE(ab8500_rtc_time_regs); i++) { retval = abx500_set_register_interruptible(dev, AB8500_RTC, @@ -185,7 +183,7 @@ static int ab8500_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) int retval, i; u8 rtc_ctrl, value; unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; - unsigned long secs, mins; + unsigned long long secs, mins;
/* Check if the alarm is enabled or not */ retval = abx500_get_register_interruptible(dev, AB8500_RTC, @@ -214,7 +212,7 @@ static int ab8500_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) /* Add back the initially subtracted number of seconds */ secs += get_elapsed_seconds(AB8500_RTC_EPOCH);
- rtc_time_to_tm(secs, &alarm->time); + rtc_time64_to_tm(secs, &alarm->time);
return rtc_valid_tm(&alarm->time); } @@ -230,7 +228,7 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { int retval, i; unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; - unsigned long mins, secs = 0, cursec = 0; + unsigned long long secs = 0, cursec = 0; struct rtc_time curtm;
if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { @@ -240,7 +238,7 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) }
/* Get the number of seconds since 1970 */ - rtc_tm_to_time(&alarm->time, &secs); + secs = rtc_tm_to_time64(&alarm->time);
/* * Check whether alarm is set less than 1min. @@ -248,7 +246,7 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) * return -EINVAL, so UIE EMUL can take it up, incase of UIE_ON */ ab8500_rtc_read_time(dev, &curtm); /* Read current time */ - rtc_tm_to_time(&curtm, &cursec); + cursec = rtc_tm_to_time64(&curtm); if ((secs - cursec) < 59) { dev_dbg(dev, "Alarm less than 1 minute not supported\r\n"); return -EINVAL; @@ -260,11 +258,11 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) */ secs -= get_elapsed_seconds(AB8500_RTC_EPOCH);
- mins = secs / 60; + do_div(secs, 60);
- buf[2] = mins & 0xFF; - buf[1] = (mins >> 8) & 0xFF; - buf[0] = (mins >> 16) & 0xFF; + buf[2] = secs & 0xFF; + buf[1] = (secs >> 8) & 0xFF; + buf[0] = (secs >> 16) & 0xFF;
/* Set the alarm time */ for (i = 0; i < ARRAY_SIZE(ab8500_rtc_alarm_regs); i++) { @@ -281,7 +279,7 @@ static int ab8540_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { int retval, i; unsigned char buf[ARRAY_SIZE(ab8540_rtc_alarm_regs)]; - unsigned long mins, secs = 0; + unsigned long long secs = 0;
if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { dev_dbg(dev, "year should be equal to or greater than %d\n", @@ -290,18 +288,17 @@ static int ab8540_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) }
/* Get the number of seconds since 1970 */ - rtc_tm_to_time(&alarm->time, &secs); + secs = rtc_tm_to_time64(&alarm->time);
/* * Convert it to the number of seconds since 01-01-2000 00:00:00 */ secs -= get_elapsed_seconds(AB8500_RTC_EPOCH); - mins = secs / 60;
- buf[3] = secs % 60; - buf[2] = mins & 0xFF; - buf[1] = (mins >> 8) & 0xFF; - buf[0] = (mins >> 16) & 0xFF; + buf[3] = do_div(secs, 60); + buf[2] = secs & 0xFF; + buf[1] = (secs >> 8) & 0xFF; + buf[0] = (secs >> 16) & 0xFF;
/* Set the alarm time */ for (i = 0; i < ARRAY_SIZE(ab8540_rtc_alarm_regs); i++) {
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
version 2: - fix compilation issues by using do_div()
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-cpcap.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c index 3a0333e..e92b346 100644 --- a/drivers/rtc/rtc-cpcap.c +++ b/drivers/rtc/rtc-cpcap.c @@ -58,24 +58,23 @@ struct cpcap_rtc { static void cpcap2rtc_time(struct rtc_time *rtc, struct cpcap_time *cpcap) { unsigned long int tod; - unsigned long int time; + unsigned long long time;
tod = (cpcap->tod1 & TOD1_MASK) | ((cpcap->tod2 & TOD2_MASK) << 8); time = tod + ((cpcap->day & DAY_MASK) * SECS_PER_DAY);
- rtc_time_to_tm(time, rtc); + rtc_time64_to_tm(time, rtc); }
static void rtc2cpcap_time(struct cpcap_time *cpcap, struct rtc_time *rtc) { - unsigned long time; + unsigned long long time, tod;
- rtc_tm_to_time(rtc, &time); - - cpcap->day = time / SECS_PER_DAY; - time %= SECS_PER_DAY; - cpcap->tod2 = (time >> 8) & TOD2_MASK; - cpcap->tod1 = time & TOD1_MASK; + time = rtc_tm_to_time64(rtc); + tod = do_div(time, SECS_PER_DAY); + cpcap->day = time; + cpcap->tod2 = (tod >> 8) & TOD2_MASK; + cpcap->tod1 = tod & TOD1_MASK; }
static int cpcap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-davinci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c index caf3556..03beba3 100644 --- a/drivers/rtc/rtc-davinci.c +++ b/drivers/rtc/rtc-davinci.c @@ -429,18 +429,18 @@ static int davinci_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) if (alm->time.tm_mday <= 0 && alm->time.tm_mon < 0 && alm->time.tm_year < 0) { struct rtc_time tm; - unsigned long now, then; + unsigned long long now, then;
davinci_rtc_read_time(dev, &tm); - rtc_tm_to_time(&tm, &now); + now = rtc_tm_to_time64(&tm);
alm->time.tm_mday = tm.tm_mday; alm->time.tm_mon = tm.tm_mon; alm->time.tm_year = tm.tm_year; - rtc_tm_to_time(&alm->time, &then); + then = rtc_tm_to_time64(&alm->time);
if (then < now) { - rtc_time_to_tm(now + 24 * 60 * 60, &tm); + rtc_time64_to_tm(now + 24 * 60 * 60, &tm); alm->time.tm_mday = tm.tm_mday; alm->time.tm_mon = tm.tm_mon; alm->time.tm_year = tm.tm_year;
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-ds1305.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 72b2293..b41168b 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c @@ -324,23 +324,20 @@ static int ds1305_set_alarm(struct device *dev, struct rtc_wkalrm *alm) { struct ds1305 *ds1305 = dev_get_drvdata(dev); struct spi_device *spi = ds1305->spi; - unsigned long now, later; + unsigned long long now, later; struct rtc_time tm; int status; u8 buf[1 + DS1305_ALM_LEN];
/* convert desired alarm to time_t */ - status = rtc_tm_to_time(&alm->time, &later); - if (status < 0) - return status; + later = rtc_tm_to_time64(&alm->time);
/* Read current time as time_t */ status = ds1305_get_time(dev, &tm); if (status < 0) return status; - status = rtc_tm_to_time(&tm, &now); - if (status < 0) - return status; + + now = rtc_tm_to_time64(&tm);
/* make sure alarm fires within the next 24 hours */ if (later <= now)
Well, again, please don't.
I'll be randomly taking this one as an example.
That RTC will fail in 2100, 6 years before rtc_tm_to_time begins to be an issue.
Once again, your patch hides the fact that there is an issue. There is no other way than reading the datasheet and actually think about what your are doing instead of using sed/coccinelle/whatever.
On 12/07/2017 at 10:04:28 +0200, Benjamin Gaignard wrote:
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org
drivers/rtc/rtc-ds1305.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 72b2293..b41168b 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c @@ -324,23 +324,20 @@ static int ds1305_set_alarm(struct device *dev, struct rtc_wkalrm *alm) { struct ds1305 *ds1305 = dev_get_drvdata(dev); struct spi_device *spi = ds1305->spi;
- unsigned long now, later;
- unsigned long long now, later; struct rtc_time tm; int status; u8 buf[1 + DS1305_ALM_LEN];
/* convert desired alarm to time_t */
- status = rtc_tm_to_time(&alm->time, &later);
- if (status < 0)
return status;
- later = rtc_tm_to_time64(&alm->time);
/* Read current time as time_t */ status = ds1305_get_time(dev, &tm); if (status < 0) return status;
- status = rtc_tm_to_time(&tm, &now);
- if (status < 0)
return status;
- now = rtc_tm_to_time64(&tm);
/* make sure alarm fires within the next 24 hours */ if (later <= now) -- 1.9.1
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-ds1511.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 1b2dcb5..3744114 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c @@ -279,7 +279,7 @@ static int ds1511_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm)
if (rtc_valid_tm(rtc_tm) < 0) { dev_err(dev, "retrieved date/time is not valid.\n"); - rtc_time_to_tm(0, rtc_tm); + rtc_time64_to_tm(0, rtc_tm); } return 0; }
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-ds1553.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index 9961ec6..dc08366 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c @@ -129,7 +129,7 @@ static int ds1553_rtc_read_time(struct device *dev, struct rtc_time *tm)
if (rtc_valid_tm(tm) < 0) { dev_err(dev, "retrieved date/time is not valid.\n"); - rtc_time_to_tm(0, tm); + rtc_time64_to_tm(0, tm); } return 0; }
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Hans Ulli Kroll ulli.kroll@googlemail.com CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org CC: linux-arm-kernel@lists.infradead.org --- drivers/rtc/rtc-ftrtc010.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-ftrtc010.c b/drivers/rtc/rtc-ftrtc010.c index af8d6be..6328913 100644 --- a/drivers/rtc/rtc-ftrtc010.c +++ b/drivers/rtc/rtc-ftrtc010.c @@ -74,7 +74,7 @@ static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm) struct ftrtc010_rtc *rtc = dev_get_drvdata(dev);
unsigned int days, hour, min, sec; - unsigned long offset, time; + unsigned long long offset, time;
sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); @@ -84,7 +84,7 @@ static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm)
time = offset + days * 86400 + hour * 3600 + min * 60 + sec;
- rtc_time_to_tm(time, tm); + rtc_time64_to_tm(time, tm);
return 0; } @@ -93,12 +93,12 @@ static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct ftrtc010_rtc *rtc = dev_get_drvdata(dev); unsigned int sec, min, hour, day; - unsigned long offset, time; + unsigned long long offset, time;
if (tm->tm_year >= 2148) /* EPOCH Year + 179 */ return -EINVAL;
- rtc_tm_to_time(tm, &time); + time = rtc_tm_to_time64(tm);
sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE);
Hi Benjamin,
On Wed, 12 Jul 2017, Benjamin Gaignard wrote:
@@ -93,12 +93,12 @@ static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct ftrtc010_rtc *rtc = dev_get_drvdata(dev); unsigned int sec, min, hour, day;
- unsigned long offset, time;
- unsigned long long offset, time;
if (tm->tm_year >= 2148) /* EPOCH Year + 179 */ return -EINVAL;
- rtc_tm_to_time(tm, &time);
- time = rtc_tm_to_time64(tm);
sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE);
later on this will do
writel(offset, rtc->rtc_base + FTRTC010_RTC_RECORD);
you are writing some 64bit value in a 32bit register ...
NACK here
Greetings from Cologne Hans Ulli Kroll
1.9.1
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-mv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index 79bb286..fce4658 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c @@ -127,7 +127,7 @@ static int mv_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
if (rtc_valid_tm(&alm->time) < 0) { dev_err(dev, "retrieved alarm date/time is not valid.\n"); - rtc_time_to_tm(0, &alm->time); + rtc_time64_to_tm(0, &alm->time); }
alm->enabled = !!readl(ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
For the same reasons use set_mmss64 callback instead of set_mmss
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-omap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 13f7cd1..8aa3957 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -432,7 +432,7 @@ static void omap_rtc_power_off(void) { struct omap_rtc *rtc = omap_rtc_power_off_rtc; struct rtc_time tm; - unsigned long now; + unsigned long long now; u32 val;
rtc->type->unlock(rtc); @@ -443,8 +443,8 @@ static void omap_rtc_power_off(void) /* set alarm two seconds from now */ omap_rtc_read_time_raw(rtc, &tm); bcd2tm(&tm); - rtc_tm_to_time(&tm, &now); - rtc_time_to_tm(now + 2, &tm); + now = rtc_tm_to_time64(&tm); + rtc_time64_to_tm(now + 2, &tm);
if (tm2bcd(&tm) < 0) { dev_err(&rtc->rtc->dev, "power off failed\n");
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
version 2: - fix compilation issues by using do_div() Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-pcap.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c index c443324..65aa6e2 100644 --- a/drivers/rtc/rtc-pcap.c +++ b/drivers/rtc/rtc-pcap.c @@ -46,7 +46,7 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) struct platform_device *pdev = to_platform_device(dev); struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev); struct rtc_time *tm = &alrm->time; - unsigned long secs; + unsigned long long secs; u32 tod; /* time of day, seconds since midnight */ u32 days; /* days since 1/1/1970 */
@@ -56,7 +56,7 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days); secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
- rtc_time_to_tm(secs, tm); + rtc_time64_to_tm(secs, tm);
return 0; } @@ -66,16 +66,14 @@ static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) struct platform_device *pdev = to_platform_device(dev); struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev); struct rtc_time *tm = &alrm->time; - unsigned long secs; - u32 tod, days; + unsigned long long secs; + u32 tod;
- rtc_tm_to_time(tm, &secs); + secs = rtc_tm_to_time64(tm);
- tod = secs % SEC_PER_DAY; + tod = do_div(secs, SEC_PER_DAY); ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod); - - days = secs / SEC_PER_DAY; - ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, days); + ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, secs);
return 0; } @@ -84,7 +82,7 @@ static int pcap_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct platform_device *pdev = to_platform_device(dev); struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev); - unsigned long secs; + unsigned long long secs; u32 tod, days;
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_TOD, &tod); @@ -93,21 +91,19 @@ static int pcap_rtc_read_time(struct device *dev, struct rtc_time *tm) ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days); secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
- rtc_time_to_tm(secs, tm); + rtc_time64_to_tm(secs, tm);
return rtc_valid_tm(tm); }
-static int pcap_rtc_set_mmss(struct device *dev, unsigned long secs) +static int pcap_rtc_set_mmss64(struct device *dev, time64_t secs) { struct platform_device *pdev = to_platform_device(dev); struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev); u32 tod, days;
- tod = secs % SEC_PER_DAY; + days = div_s64_rem(secs, SEC_PER_DAY, &tod); ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TOD, tod); - - days = secs / SEC_PER_DAY; ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAY, days);
return 0; @@ -135,7 +131,7 @@ static int pcap_rtc_alarm_irq_enable(struct device *dev, unsigned int en) .read_time = pcap_rtc_read_time, .read_alarm = pcap_rtc_read_alarm, .set_alarm = pcap_rtc_set_alarm, - .set_mmss = pcap_rtc_set_mmss, + .set_mmss64 = pcap_rtc_set_mmss64, .alarm_irq_enable = pcap_rtc_alarm_irq_enable, };
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-rs5c348.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index 9a30698..f82c0bc 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c @@ -137,7 +137,7 @@ struct rs5c348_plat_data {
if (rtc_valid_tm(tm) < 0) { dev_err(&spi->dev, "retrieved date/time is not valid.\n"); - rtc_time_to_tm(0, tm); + rtc_time64_to_tm(0, tm); }
return 0; @@ -183,7 +183,7 @@ static int rs5c348_probe(struct spi_device *spi) dev_warn(&spi->dev, "voltage-low detected.\n"); if (ret & RS5C348_BIT_XSTP) dev_warn(&spi->dev, "oscillator-stop detected.\n"); - rtc_time_to_tm(0, &tm); /* 1970/1/1 */ + rtc_time64_to_tm(0, &tm); /* 1970/1/1 */ ret = rs5c348_rtc_set_time(&spi->dev, &tm); if (ret < 0) goto kfree_exit;
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-sh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 6c2d398..f65da1e 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c @@ -694,7 +694,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
/* reset rtc to epoch 0 if time is invalid */ if (rtc_read_time(rtc->rtc_dev, &r) < 0) { - rtc_time_to_tm(0, &r); + rtc_time64_to_tm(0, &r); rtc_set_time(rtc->rtc_dev, &r); }
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-snvs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index d8ef9e0..774048e 100644 --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c @@ -121,9 +121,9 @@ static int snvs_rtc_enable(struct snvs_rtc_data *data, bool enable) static int snvs_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct snvs_rtc_data *data = dev_get_drvdata(dev); - unsigned long time = rtc_read_lp_counter(data); + unsigned long long time = rtc_read_lp_counter(data);
- rtc_time_to_tm(time, tm); + rtc_time64_to_tm(time, tm);
return 0; } @@ -131,9 +131,9 @@ static int snvs_rtc_read_time(struct device *dev, struct rtc_time *tm) static int snvs_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct snvs_rtc_data *data = dev_get_drvdata(dev); - unsigned long time; + unsigned long long time;
- rtc_tm_to_time(tm, &time); + time = rtc_tm_to_time64(tm);
/* Disable RTC first */ snvs_rtc_enable(data, false); @@ -154,7 +154,7 @@ static int snvs_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) u32 lptar, lpsr;
regmap_read(data->regmap, data->offset + SNVS_LPTAR, &lptar); - rtc_time_to_tm(lptar, &alrm->time); + rtc_time64_to_tm((u64)lptar, &alrm->time);
regmap_read(data->regmap, data->offset + SNVS_LPSR, &lpsr); alrm->pending = (lpsr & SNVS_LPSR_LPTA) ? 1 : 0; @@ -179,9 +179,9 @@ static int snvs_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) { struct snvs_rtc_data *data = dev_get_drvdata(dev); struct rtc_time *alrm_tm = &alrm->time; - unsigned long time; + unsigned long long time;
- rtc_tm_to_time(alrm_tm, &time); + time = rtc_tm_to_time64(alrm_tm);
regmap_update_bits(data->regmap, data->offset + SNVS_LPCR, SNVS_LPCR_LPTA_EN, 0); rtc_write_sync_lp(data);
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-stk17ta8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c index a456cb6..5a0dca9 100644 --- a/drivers/rtc/rtc-stk17ta8.c +++ b/drivers/rtc/rtc-stk17ta8.c @@ -131,7 +131,7 @@ static int stk17ta8_rtc_read_time(struct device *dev, struct rtc_time *tm)
if (rtc_valid_tm(tm) < 0) { dev_err(dev, "retrieved date/time is not valid.\n"); - rtc_time_to_tm(0, tm); + rtc_time64_to_tm(0, tm); } return 0; }
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Maxime Ripard maxime.ripard@free-electrons.com CC: Chen-Yu Tsai wens@csie.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org CC: linux-arm-kernel@lists.infradead.org --- drivers/rtc/rtc-sun6i.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index 39cbc12..9928f74 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -120,7 +120,7 @@ struct sun6i_rtc_dev { struct device *dev; void __iomem *base; int irq; - unsigned long alarm; + unsigned long long alarm;
struct clk_hw hw; struct clk_hw *int_osc; @@ -342,7 +342,7 @@ static int sun6i_rtc_getalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
wkalrm->enabled = !!(alrm_en & SUN6I_ALRM_EN_CNT_EN); wkalrm->pending = !!(alrm_st & SUN6I_ALRM_EN_CNT_EN); - rtc_time_to_tm(chip->alarm, &wkalrm->time); + rtc_time64_to_tm(chip->alarm, &wkalrm->time);
return 0; } @@ -352,9 +352,9 @@ static int sun6i_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm) struct sun6i_rtc_dev *chip = dev_get_drvdata(dev); struct rtc_time *alrm_tm = &wkalrm->time; struct rtc_time tm_now; - unsigned long time_now = 0; - unsigned long time_set = 0; - unsigned long time_gap = 0; + unsigned long long time_now = 0; + unsigned long long time_set = 0; + unsigned long long time_gap = 0; int ret = 0;
ret = sun6i_rtc_gettime(dev, &tm_now); @@ -363,8 +363,8 @@ static int sun6i_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm) return -EINVAL; }
- rtc_tm_to_time(alrm_tm, &time_set); - rtc_tm_to_time(&tm_now, &time_now); + time_set = rtc_tm_to_time64(alrm_tm); + time_now = rtc_tm_to_time64(&tm_now); if (time_set <= time_now) { dev_err(dev, "Date to set in the past\n"); return -EINVAL;
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.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..8b97def 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); + unsigned long long time; + + time = rtc_tm_to_time64(&tm); + retval = sprintf(buf, "%llu\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; + unsigned long long 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, "%llu\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; + unsigned long long now, alarm; + unsigned long long 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 = kstrtoull(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;
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
For the same reasons use set_mmss64 callback instead of set_mmss Since only set_mmss64 be will used remove module parameter.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-test.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c index 3a2da4c..6a460e3 100644 --- a/drivers/rtc/rtc-test.c +++ b/drivers/rtc/rtc-test.c @@ -13,10 +13,6 @@ #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, @@ -44,12 +40,6 @@ static int test_rtc_set_mmss64(struct device *dev, time64_t secs) return 0; }
-static int test_rtc_set_mmss(struct device *dev, unsigned long secs) -{ - dev_info(dev, "%s, secs = %lu\n", __func__, secs); - return 0; -} - static int test_rtc_proc(struct device *dev, struct seq_file *seq) { struct platform_device *plat_dev = to_platform_device(dev); @@ -70,7 +60,7 @@ static int test_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) .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_mmss64, .alarm_irq_enable = test_rtc_alarm_irq_enable, };
@@ -111,11 +101,6 @@ 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)) {
rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones.
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org Acked-by: Pavel Machek pavel@ucw.cz CC: "Rafael J. Wysocki" rjw@rjwysocki.net CC: Pavel Machek pavel@ucw.cz CC: Len Brown len.brown@intel.com CC: Alessandro Zummo a.zummo@towertech.it CC: Alexandre Belloni alexandre.belloni@free-electrons.com CC: rtc-linux@googlegroups.com CC: linux-pm@vger.kernel.org CC: linux-kernel@vger.kernel.org --- kernel/power/suspend_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/power/suspend_test.c b/kernel/power/suspend_test.c index 5db2170..334a893 100644 --- a/kernel/power/suspend_test.c +++ b/kernel/power/suspend_test.c @@ -71,7 +71,7 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state) static char info_test[] __initdata = KERN_INFO "PM: test RTC wakeup from '%s' suspend\n";
- unsigned long now; + unsigned long long now; struct rtc_wkalrm alm; int status;
@@ -82,10 +82,10 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state) printk(err_readtime, dev_name(&rtc->dev), status); return; } - rtc_tm_to_time(&alm.time, &now); + now = rtc_tm_to_time64(&alm.time);
memset(&alm, 0, sizeof alm); - rtc_time_to_tm(now + TEST_SUSPEND_SECONDS, &alm.time); + rtc_time64_to_tm(now + TEST_SUSPEND_SECONDS, &alm.time); alm.enabled = true;
status = rtc_set_alarm(rtc, &alm);
On 12-07-17, 10:04, Benjamin Gaignard wrote:
rtc_time_to_tm() and rtc_tm_to_time() are using 32 bits variables so they may break in y2038/2106.
This patcheset is a subset (22 vs 51) of the first version where I have only updated the drivers where I believe using 64 bits functions could help. For example hardwares using BCD like time encoding or those storing date in more than 32 bits are in this series.
I have rebase my patches on top of rtc-next and fix the errors reported by Kbuild.
While it is a good idea to cc linaro list for your patches, but you made a mistake by not cc'ing LKML for the cover-letter of this series (or any other open list for that matter). :)
Perhaps you relied on tocmd and cccmd, which don't really work on coverletters :(
Attaching my copies of those scripts, in case they help you.
linaro-kernel@lists.linaro.org