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.gaign...@linaro.org>
CC: Alessandro Zummo <a.zu...@towertech.it>
CC: Alexandre Belloni <alexandre.bell...@free-electrons.com>
CC: rtc-linux@googlegroups.com
CC: linux-ker...@vger.kernel.org
---
 drivers/rtc/rtc-pm8xxx.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index fac8355..e6b52bd 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -81,7 +81,8 @@ struct pm8xxx_rtc {
 static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
        int rc, i;
-       unsigned long secs, irq_flags;
+       unsigned long long secs;
+       unsigned long irq_flags;
        u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0;
        unsigned int ctrl_reg;
        struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
@@ -90,14 +91,14 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
        if (!rtc_dd->allow_set_time)
                return -EACCES;
 
-       rtc_tm_to_time(tm, &secs);
+       secs = rtc_tm_to_time64(tm);
 
        for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) {
                value[i] = secs & 0xFF;
                secs >>= 8;
        }
 
-       dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs);
+       dev_dbg(dev, "Seconds value to be written to RTC = %llu\n", secs);
 
        spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
 
@@ -156,7 +157,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 {
        int rc;
        u8 value[NUM_8_BIT_RTC_REGS];
-       unsigned long secs;
+       unsigned long long secs;
        unsigned int reg;
        struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
        const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
@@ -188,7 +189,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 
        secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
 
-       rtc_time_to_tm(secs, tm);
+       rtc_time64_to_tm(secs, tm);
 
        rc = rtc_valid_tm(tm);
        if (rc < 0) {
@@ -196,7 +197,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
                return rc;
        }
 
-       dev_dbg(dev, "secs = %lu, h:m:s == %d:%d:%d, d/m/y = %d/%d/%d\n",
+       dev_dbg(dev, "secs = %llu, h:m:s == %d:%d:%d, d/m/y = %d/%d/%d\n",
                secs, tm->tm_hour, tm->tm_min, tm->tm_sec,
                tm->tm_mday, tm->tm_mon, tm->tm_year);
 
@@ -208,11 +209,12 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, 
struct rtc_wkalrm *alarm)
        int rc, i;
        u8 value[NUM_8_BIT_RTC_REGS];
        unsigned int ctrl_reg;
-       unsigned long secs, irq_flags;
+       unsigned long long secs;
+       unsigned long irq_flags;
        struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
        const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
 
-       rtc_tm_to_time(&alarm->time, &secs);
+       secs = rtc_tm_to_time64(&alarm->time);
 
        for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) {
                value[i] = secs & 0xFF;
@@ -256,7 +258,7 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
 {
        int rc;
        u8 value[NUM_8_BIT_RTC_REGS];
-       unsigned long secs;
+       unsigned long long secs;
        struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
        const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
 
@@ -269,7 +271,7 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
 
        secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
 
-       rtc_time_to_tm(secs, &alarm->time);
+       rtc_time64_to_tm(secs, &alarm->time);
 
        rc = rtc_valid_tm(&alarm->time);
        if (rc < 0) {
-- 
1.9.1

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups 
"rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rtc-linux+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to