[rtc-linux] [PATCH v2 18/22] rtc: stk17ta8: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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-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;
 }
-- 
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.


[rtc-linux] [PATCH v2 14/22] rtc: pcap: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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.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-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 = >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, );
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 = >time;
-   unsigned long secs;
-   u32 tod, days;
+   unsigned long long secs;
+   u32 tod;
 
-   rtc_tm_to_time(tm, );
+   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, );
@@ -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, );
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, );
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,
 };
 
-- 
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.


[rtc-linux] [PATCH v2 21/22] rtc: test: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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.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-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 
 #include 
 
-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(_dev->dev, "test",
_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
-- 
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.


[rtc-linux] [PATCH v2 05/22] rtc: ab8500: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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.gaign...@linaro.org>
Acked-by: Linus Walleij <linus.wall...@linaro.org>
CC: Linus Walleij <linus.wall...@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
CC: linux-arm-ker...@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(, );
+   secs = rtc_tm_to_time64();
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 = 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, >time);
+   rtc_time64_to_tm(secs, >time);
 
return rtc_valid_tm(>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 devic

[rtc-linux] [PATCH v2 08/22] rtc: ds1305: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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-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(>time, );
-   if (status < 0)
-   return status;
+   later = rtc_tm_to_time64(>time);
 
/* Read current time as time_t */
status = ds1305_get_time(dev, );
if (status < 0)
return status;
-   status = rtc_tm_to_time(, );
-   if (status < 0)
-   return status;
+
+   now = rtc_tm_to_time64();
 
/* make sure alarm fires within the next 24 hours */
if (later <= now)
-- 
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.


[rtc-linux] [PATCH v2 09/22] rtc: ds1511: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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-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;
 }
-- 
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.


[rtc-linux] [PATCH v2 22/22] power: suspend test: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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>
Acked-by: Pavel Machek <pa...@ucw.cz>
CC: "Rafael J. Wysocki" <r...@rjwysocki.net>
CC: Pavel Machek <pa...@ucw.cz>
CC: Len Brown <len.br...@intel.com>
CC: Alessandro Zummo <a.zu...@towertech.it>
CC: Alexandre Belloni <alexandre.bell...@free-electrons.com>
CC: rtc-linux@googlegroups.com
CC: linux...@vger.kernel.org
CC: linux-ker...@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(>dev), status);
return;
}
-   rtc_tm_to_time(, );
+   now = rtc_tm_to_time64();
 
memset(, 0, sizeof alm);
-   rtc_time_to_tm(now + TEST_SUSPEND_SECONDS, );
+   rtc_time64_to_tm(now + TEST_SUSPEND_SECONDS, );
alm.enabled = true;
 
status = rtc_set_alarm(rtc, );
-- 
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.


[rtc-linux] [PATCH v2 12/22] rtc: mv: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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-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(>time) < 0) {
dev_err(dev, "retrieved alarm date/time is not valid.\n");
-   rtc_time_to_tm(0, >time);
+   rtc_time64_to_tm(0, >time);
}
 
alm->enabled = !!readl(ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
-- 
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.


[rtc-linux] [PATCH v2 04/22] rtc: ab-b5ze-s3: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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-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 = >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(_tm, _secs);
-   if (ret)
-   goto err;
+   rtc_secs = rtc_tm_to_time64(_tm);
 
/* ... add remaining timer A time ... */
ret = sec_from_timer_a(_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 = >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(_tm, _secs);
-   if (ret)
-   goto err;
-
-   ret = rtc_tm_to_time(alarm_tm, _secs);
-   if (ret)
-   goto err;
+   rtc_secs = rtc_tm_to_time64(_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 = >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(_tm, _secs);
-   if (ret)
-   goto err;
-
-   ret = rtc_tm_to_time(alarm_tm, _secs);
-   if (ret)
-   goto err;
+   rtc_secs = rtc_tm_to_time64(_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(_tm, _secs);
-   if (ret)
-   goto err;
+   rtc_secs = rtc_tm_to_time64(_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 = >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(_tm, _secs);
-   if (ret)
-   goto err;
-
-   ret = rtc_tm_to_time(alarm_tm, _secs);
-   if (ret)
-   goto err;
+   rtc_secs = rtc_tm_to_time64(_tm);
+   alarm_secs = rtc_tm_to_time64(alarm_tm);
 
/* Let's first disable both the alarm and the 

[rtc-linux] [PATCH v2 06/22] rtc: cpcap: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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.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-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, );
-
-   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)
-- 
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.


[rtc-linux] [PATCH v2 19/22] rtc: sun6i: stop using rtc deprecated functions

2017-07-12 Thread Benjamin Gaignard
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: Maxime Ripard <maxime.rip...@free-electrons.com>
CC: Chen-Yu Tsai <w...@csie.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
CC: linux-arm-ker...@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, >time);
+   rtc_time64_to_tm(chip->alarm, >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 = >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, _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, _set);
-   rtc_tm_to_time(_now, _now);
+   time_set = rtc_tm_to_time64(alrm_tm);
+   time_now = rtc_tm_to_time64(_now);
if (time_set <= time_now) {
dev_err(dev, "Date to set in the past\n");
return -EINVAL;
-- 
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.


[rtc-linux] Re: [PATCH v2 0/3] rtc: make st-lpc robust against y2038/2106 bug

2017-07-04 Thread Benjamin Gaignard
2017-06-24 0:34 GMT+02:00 Shuah Khan <sh...@kernel.org>:
> Hi Alexandre,
>
> On 06/23/2017 04:09 PM, Alexandre Belloni wrote:
>> On 23/06/2017 at 13:40:41 -0600, Shuah Khan wrote:
>>> On 06/19/2017 03:36 AM, Benjamin Gaignard wrote:
>>>> On 32bits platforms "struct timeval" or "time_t" are using u32 to code the
>>>> date, this cause tools like "date" or "hwclock" failed even before setting
>>>> the RTC device if the date is superior to year 2038 (or 2106).
>>>>
>>>> To avoid this problem I add one RTC test file which directly use RTC ioctl
>>>> to set and read RTC time and alarm values.
>>>> rtctest_setdate allow to set any date/time given in the command line.
>>>>
>>>> On this version 2 I add check of problematics years in rtctest like suggest
>>>> by Alexandre.
>>>>
>>>> Finally that had allowed me to test and fix rtc-st-lpc driver.
>>>>
>>>> Benjamin Gaignard (3):
>>>>   tools: timer: add rtctest_setdate
>>>>   tool: timer: rtctest add check for problematic dates
>>>>   rtc: st-lpc: make it robust against y2038/2106 bug
>>>>
>>>>  drivers/rtc/rtc-st-lpc.c |  19 ++--
>>>>  tools/testing/selftests/timers/Makefile  |   2 +-
>>>>  tools/testing/selftests/timers/rtctest.c | 121 
>>>> ++-
>>>>  tools/testing/selftests/timers/rtctest_setdate.c |  86 
>>>>  4 files changed, 212 insertions(+), 16 deletions(-)
>>>>  create mode 100644 tools/testing/selftests/timers/rtctest_setdate.c
>>>>
>>>
>>> Hi Thomas/John,
>>>
>>> I can take the first two patches in this series through linux-kselftest
>>> with your or John's Ack. Please review and let me know one way or the
>>> other.
>>>>
>> Well, I'm the maintainer for rtctest.c and I'll make sure to also be the
>> one for rtctest_setdate.c>
>>> The third one is a rtc driver patch. Please let me know how do you want
>>> to handle this series soon we can get this into 4.13-rc1.
>>>
>>
>> I'll take the three patches but I still have comment I didn't have time
>> to give yet.

Alexandre, may you had time to give me feedback on this ?

Regards,
Benjamin

>>
>>
>
> Okay. I will drop this off my radar then :)
>
> thanks,
> -- Shuah
>

-- 
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.


[rtc-linux] Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

2017-06-21 Thread Benjamin Gaignard
2017-06-21 0:08 GMT+02:00 Pavel Machek :
> Hi!
>
>> >> > This is it.
>> >> > https://patchwork.kernel.org/patch/6219401/
>> >>
>> >> Thanks.
>> >>
>> >> Yes, that's argument against changing rtc _drivers_ for hardware that
>> >> can not do better than 32bit. For generic code (such as 44/51 sysfs,
>> >> 51/51 suspend test), the change still makes sense.
>>
>> What I had in mind when writing those patches was to remove the limitations
>> coming from those functions usage, even more since they been marked has
>> deprecated.
>>
>> I agree that will change nothing of hardware limitation but at least
>> the limit will
>> not come from the framework.
>
>> > Yes, we agree on that but I won't cherry pick working patches from a 51
>> > patches series.
>
> Well, it would be actually nice for you to do the cherry
> picking. That's something maintainers do, because it is hard for
> contributors to guess maintainer's taste.
>
> Anyway, it looks like someone should go through all the RTC drivers,
> and document their limitations of each driver (date in future when
> hardware ceases to be useful). If Benjamin has time to do that, I
> guess that removes all the objections to the series.

Without the datasheet I can check in driver code what they do in read/set
time functions to understand their limitations. All drivers using BCD
like system
or spliting day and time should be fixed. I can do a subset of my patches
including those driver + the acked ones.

Alexandre does that sound reasonable for you ?


> Regards,
> Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) 
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

-- 
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.


[rtc-linux] Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
2017-06-20 15:48 GMT+02:00 Alexandre Belloni
<alexandre.bell...@free-electrons.com>:
> On 20/06/2017 at 15:44:58 +0200, Pavel Machek wrote:
>> On Tue 2017-06-20 13:37:22, Steve Twiss wrote:
>> > Hi Pavel,
>> >
>> > On 20 June 2017 14:26, Pavel Machek wrote:
>> >
>> > > Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions
>> > >
>> > > On Tue 2017-06-20 14:24:00, Alexandre Belloni wrote:
>> > > > On 20/06/2017 at 14:10:11 +0200, Pavel Machek wrote:
>> > > > > On Tue 2017-06-20 12:03:48, Alexandre Belloni wrote:
>> > > > > > On 20/06/2017 at 11:35:08 +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.
>> > > > > >
>> > > > > > Please don't, because this hide the fact that the hardware will not
>> > > > > > handle dates in y2038 anyway and as pointed by Russell a few month 
>> > > > > > ago,
>> > > > > > rtc_time_to_tm will be able to catch it but the 64 bit version will
>> > > > > > silently ignore it.
>> > > > >
>> > > > > Reference? Because rtc on PCs stores date in binary coded decimal, so
>> > > > > it is likely to break in 2100, not 2038...
>> > > >
>> > > > I'm not saying it should be done but clearly, that is not the correct
>> > > > thing to do for RTCs that are using a single 32 bits register to store
>> > > > the time.
>> > > > You give one example, I can give you three: armada38x, at91sam9,
>> > > > at32ap700x and that just in the beginning of the series.
>> > >
>> > > I wanted reference to Russell's mail.
>> >
>> > This is it.
>> > https://patchwork.kernel.org/patch/6219401/
>>
>> Thanks.
>>
>> Yes, that's argument against changing rtc _drivers_ for hardware that
>> can not do better than 32bit. For generic code (such as 44/51 sysfs,
>> 51/51 suspend test), the change still makes sense.

What I had in mind when writing those patches was to remove the limitations
coming from those functions usage, even more since they been marked has
deprecated.

I agree that will change nothing of hardware limitation but at least
the limit will
not come from the framework.

>>
>
> Yes, we agree on that but I won't cherry pick working patches from a 51
> patches series.

maybe only the acked ones ?

>
>
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

-- 
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.


[rtc-linux] Re: [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
2017-06-20 15:41 GMT+02:00 Steve Twiss <stwiss.opensou...@diasemi.com>:
> Hi Benjamin,
>
> On 20 June 2017 10:35, Benjamin Gaignard wrote:
>
>> Subject: [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions
>
> Probably this subject should be "rtc: da9052" not 63.

yes you are right this patch is for da9052

>
>> 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.
>>
> [...]
>
>> ---
>>  drivers/rtc/rtc-da9052.c | 8 +++-
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
>> index 4273377..99a0489 100644
>> --- a/drivers/rtc/rtc-da9052.c
>> +++ b/drivers/rtc/rtc-da9052.c
>> @@ -104,17 +104,15 @@ static int da9052_read_alarm(struct da9052_rtc
>> *rtc, struct rtc_time *rtc_tm)
>>  static int da9052_set_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm)
>>  {
>>   struct da9052 *da9052 = rtc->da9052;
>> - unsigned long alm_time;
>> + unsigned long long alm_time;
>>   int ret;
>>   uint8_t v[3];
>>
>> - ret = rtc_tm_to_time(rtc_tm, _time);
>> - if (ret != 0)
>> - return ret;
>> + alm_time = rtc_tm_to_time64(rtc_tm);
>
> But they kind of use the same functions anyway.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/rtc.h?h=v4.12-rc6#n35
> And I think they they are abstracted on purpose.
>
> The DA9052/53 hardware can only handle alarms up to the end of 2063.

That is the hardware limits but I don't know if we should align
framework functions to
for each driver limitation or use 64 bits functions everywhere.
but this discussion is on going on another thread...
>
> Regards,
> Steve
>

-- 
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.


[rtc-linux] [PATCH 46/51] rtc: test: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.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-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 
 #include 
 
-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(_dev->dev, "test",
_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
-- 
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.


[rtc-linux] [PATCH 39/51] rtc: sirfsoc: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Barry Song <bao...@kernel.org>
CC: rtc-linux@googlegroups.com
CC: linux-ker...@vger.kernel.org
CC: linux-arm-ker...@lists.infradead.org
---
 drivers/rtc/rtc-sirfsoc.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/rtc/rtc-sirfsoc.c b/drivers/rtc/rtc-sirfsoc.c
index 7367f61..972ede9 100644
--- a/drivers/rtc/rtc-sirfsoc.c
+++ b/drivers/rtc/rtc-sirfsoc.c
@@ -91,11 +91,11 @@ static int sirfsoc_rtc_read_alarm(struct device *dev,
 */
/* if alarm is in next overflow cycle */
if (rtc_count > rtc_alarm)
-   rtc_time_to_tm((rtcdrv->overflow_rtc + 1)
-   << (BITS_PER_LONG - RTC_SHIFT)
-   | rtc_alarm >> RTC_SHIFT, &(alrm->time));
+   rtc_time64_to_tm((rtcdrv->overflow_rtc + 1)
+ << (BITS_PER_LONG - RTC_SHIFT)
+ | rtc_alarm >> RTC_SHIFT, &(alrm->time));
else
-   rtc_time_to_tm(rtcdrv->overflow_rtc
+   rtc_time64_to_tm(rtcdrv->overflow_rtc
<< (BITS_PER_LONG - RTC_SHIFT)
| rtc_alarm >> RTC_SHIFT, &(alrm->time));
if (sirfsoc_rtc_readl(rtcdrv, RTC_STATUS) & SIRFSOC_RTC_AL0E)
@@ -109,12 +109,12 @@ static int sirfsoc_rtc_read_alarm(struct device *dev,
 static int sirfsoc_rtc_set_alarm(struct device *dev,
struct rtc_wkalrm *alrm)
 {
-   unsigned long rtc_status_reg, rtc_alarm;
+   unsigned long long rtc_status_reg, rtc_alarm;
struct sirfsoc_rtc_drv *rtcdrv;
rtcdrv = dev_get_drvdata(dev);
 
if (alrm->enabled) {
-   rtc_tm_to_time(&(alrm->time), _alarm);
+   rtc_alarm = rtc_tm_to_time64(>time);
 
spin_lock_irq(>lock);
 
@@ -182,7 +182,7 @@ static int sirfsoc_rtc_read_time(struct device *dev,
cpu_relax();
} while (tmp_rtc != sirfsoc_rtc_readl(rtcdrv, RTC_CN));
 
-   rtc_time_to_tm(rtcdrv->overflow_rtc << (BITS_PER_LONG - RTC_SHIFT) |
+   rtc_time64_to_tm(rtcdrv->overflow_rtc << (BITS_PER_LONG - RTC_SHIFT) |
tmp_rtc >> RTC_SHIFT, tm);
return 0;
 }
@@ -190,11 +190,11 @@ static int sirfsoc_rtc_read_time(struct device *dev,
 static int sirfsoc_rtc_set_time(struct device *dev,
struct rtc_time *tm)
 {
-   unsigned long rtc_time;
+   unsigned long long rtc_time;
struct sirfsoc_rtc_drv *rtcdrv;
rtcdrv = dev_get_drvdata(dev);
 
-   rtc_tm_to_time(tm, _time);
+   rtc_time = rtc_tm_to_time64(tm);
 
rtcdrv->overflow_rtc = rtc_time >> (BITS_PER_LONG - RTC_SHIFT);
 
-- 
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.


[rtc-linux] [PATCH 27/51] rtc: imxdi: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.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-imxdi.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 6b54f6c..9af601d 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -549,10 +549,10 @@ static int di_write_wait(struct imxdi_dev *imxdi, u32 
val, int reg)
 static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
struct imxdi_dev *imxdi = dev_get_drvdata(dev);
-   unsigned long now;
+   unsigned long long now;
 
now = readl(imxdi->ioaddr + DTCMR);
-   rtc_time_to_tm(now, tm);
+   rtc_time64_to_tm(now, tm);
 
return 0;
 }
@@ -561,7 +561,7 @@ static int dryice_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
  * set the seconds portion of dryice time counter and clear the
  * fractional part.
  */
-static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int dryice_rtc_set_mmss64(struct device *dev, time64_t secs)
 {
struct imxdi_dev *imxdi = dev_get_drvdata(dev);
u32 dcr, dsr;
@@ -618,7 +618,7 @@ static int dryice_rtc_read_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
u32 dcamr;
 
dcamr = readl(imxdi->ioaddr + DCAMR);
-   rtc_time_to_tm(dcamr, >time);
+   rtc_time64_to_tm((u64)dcamr, >time);
 
/* alarm is enabled if the interrupt is enabled */
alarm->enabled = (readl(imxdi->ioaddr + DIER) & DIER_CAIE) != 0;
@@ -641,12 +641,10 @@ static int dryice_rtc_set_alarm(struct device *dev, 
struct rtc_wkalrm *alarm)
 {
struct imxdi_dev *imxdi = dev_get_drvdata(dev);
unsigned long now;
-   unsigned long alarm_time;
+   unsigned long long alarm_time;
int rc;
 
-   rc = rtc_tm_to_time(>time, _time);
-   if (rc)
-   return rc;
+   alarm_time = rtc_tm_to_time64(>time);
 
/* don't allow setting alarm in the past */
now = readl(imxdi->ioaddr + DTCMR);
@@ -668,7 +666,7 @@ static int dryice_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
 
 static const struct rtc_class_ops dryice_rtc_ops = {
.read_time  = dryice_rtc_read_time,
-   .set_mmss   = dryice_rtc_set_mmss,
+   .set_mmss64 = dryice_rtc_set_mmss64,
.alarm_irq_enable   = dryice_rtc_alarm_irq_enable,
.read_alarm = dryice_rtc_read_alarm,
.set_alarm  = dryice_rtc_set_alarm,
-- 
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.


[rtc-linux] [PATCH 47/51] rtc: tps6586: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-tps6586x.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/rtc/rtc-tps6586x.c b/drivers/rtc/rtc-tps6586x.c
index a3418a8..2383636 100644
--- a/drivers/rtc/rtc-tps6586x.c
+++ b/drivers/rtc/rtc-tps6586x.c
@@ -71,7 +71,7 @@ static int tps6586x_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
struct tps6586x_rtc *rtc = dev_get_drvdata(dev);
struct device *tps_dev = to_tps6586x_dev(dev);
unsigned long long ticks = 0;
-   unsigned long seconds;
+   unsigned long long seconds;
u8 buff[6];
int ret;
int i;
@@ -89,7 +89,7 @@ static int tps6586x_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 
seconds = ticks >> 10;
seconds += rtc->epoch_start;
-   rtc_time_to_tm(seconds, tm);
+   rtc_time64_to_tm(seconds, tm);
return rtc_valid_tm(tm);
 }
 
@@ -98,18 +98,18 @@ static int tps6586x_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
struct tps6586x_rtc *rtc = dev_get_drvdata(dev);
struct device *tps_dev = to_tps6586x_dev(dev);
unsigned long long ticks;
-   unsigned long seconds;
+   unsigned long long seconds;
u8 buff[5];
int ret;
 
-   rtc_tm_to_time(tm, );
+   seconds = rtc_tm_to_time64(tm);
if (seconds < rtc->epoch_start) {
dev_err(dev, "requested time unsupported\n");
return -EINVAL;
}
seconds -= rtc->epoch_start;
 
-   ticks = (unsigned long long)seconds << 10;
+   ticks = seconds << 10;
buff[0] = (ticks >> 32) & 0xff;
buff[1] = (ticks >> 24) & 0xff;
buff[2] = (ticks >> 16) & 0xff;
@@ -157,16 +157,16 @@ static int tps6586x_rtc_set_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
 {
struct tps6586x_rtc *rtc = dev_get_drvdata(dev);
struct device *tps_dev = to_tps6586x_dev(dev);
-   unsigned long seconds;
-   unsigned long ticks;
-   unsigned long rtc_current_time;
+   unsigned long long seconds;
+   unsigned long long ticks;
+   unsigned long long rtc_current_time;
unsigned long long rticks = 0;
u8 buff[3];
u8 rbuff[6];
int ret;
int i;
 
-   rtc_tm_to_time(>time, );
+   seconds = rtc_tm_to_time64(>time);
 
if (alrm->enabled && (seconds < rtc->epoch_start)) {
dev_err(dev, "can't set alarm to requested time\n");
@@ -196,7 +196,7 @@ static int tps6586x_rtc_set_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
if ((seconds - rtc_current_time) > ALM1_VALID_RANGE_IN_SEC)
seconds = rtc_current_time - 1;
 
-   ticks = (unsigned long long)seconds << 10;
+   ticks = seconds << 10;
buff[0] = (ticks >> 16) & 0xff;
buff[1] = (ticks >> 8) & 0xff;
buff[2] = ticks & 0xff;
@@ -212,8 +212,8 @@ static int tps6586x_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
 {
struct tps6586x_rtc *rtc = dev_get_drvdata(dev);
struct device *tps_dev = to_tps6586x_dev(dev);
-   unsigned long ticks;
-   unsigned long seconds;
+   unsigned long long ticks;
+   unsigned long long seconds;
u8 buff[3];
int ret;
 
@@ -227,7 +227,7 @@ static int tps6586x_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
seconds = ticks >> 10;
seconds += rtc->epoch_start;
 
-   rtc_time_to_tm(seconds, >time);
+   rtc_time64_to_tm(seconds, >time);
return 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.


[rtc-linux] [PATCH 44/51] rtc: sysfs: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-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), );
if (retval == 0) {
-   unsigned long time;
-   rtc_tm_to_time(, );
-   retval = sprintf(buf, "%lu\n", time);
+   unsigned long long time;
+
+   time = rtc_tm_to_time64();
+   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), );
if (retval == 0 && alm.enabled) {
-   rtc_tm_to_time(, );
-   retval = sprintf(buf, "%lu\n", alarm);
+   alarm = rtc_tm_to_time64();
+   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, );
if (retval < 0)
return retval;
-   rtc_tm_to_time(, );
+   now = rtc_tm_to_time64();
 
buf_ptr = buf;
if (*buf_ptr == '+') {
@@ -181,7 +182,7 @@
} else
adjust = 1;
}
-   retval = kstrtoul(buf_ptr, 0, );
+   retval = kstrtoull(buf_ptr, 0, );
if (retval)
return retval;
if (adjust) {
@@ -197,7 +198,7 @@
return retval;
if (alm.enabled) {
if (push) {
-   rtc_tm_to_time(, );
+   push = rtc_tm_to_time64();
alarm += push;
} else
return -EBUSY;
@@ -212,7 +213,7 @@
 */
alarm = now + 300;
}
-   rtc_time_to_tm(alarm, );
+   rtc_time64_to_tm(alarm, );
 
retval = rtc_set_alarm(rtc, );
return (retval < 0) ? retval : n;
-- 
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.


[rtc-linux] [PATCH 35/51] rtc: pm8xxx: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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 = 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(_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(>time, );
+   secs = rtc_tm_to_time64(>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, >time);
+   rtc_time64_to_tm(secs, >time);
 
rc = rtc_valid_tm(>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.


[rtc-linux] [PATCH 43/51] rtc: sun6i: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Maxime Ripard <maxime.rip...@free-electrons.com>
CC: Chen-Yu Tsai <w...@csie.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
CC: linux-arm-ker...@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, >time);
+   rtc_time64_to_tm(chip->alarm, >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 = >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, _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, _set);
-   rtc_tm_to_time(_now, _now);
+   time_set = rtc_tm_to_time64(alrm_tm);
+   time_now = rtc_tm_to_time64(_now);
if (time_set <= time_now) {
dev_err(dev, "Date to set in the past\n");
return -EINVAL;
-- 
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.


[rtc-linux] [PATCH 37/51] rtc: sa1100: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-sa1100.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index c2187bf..8645b9a 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -155,20 +155,19 @@ static int sa1100_rtc_read_time(struct device *dev, 
struct rtc_time *tm)
 {
struct sa1100_rtc *info = dev_get_drvdata(dev);
 
-   rtc_time_to_tm(readl_relaxed(info->rcnr), tm);
+   rtc_time64_to_tm(readl_relaxed(info->rcnr), tm);
return 0;
 }
 
 static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
struct sa1100_rtc *info = dev_get_drvdata(dev);
-   unsigned long time;
-   int ret;
+   unsigned long long time;
 
-   ret = rtc_tm_to_time(tm, );
-   if (ret == 0)
-   writel_relaxed(time, info->rcnr);
-   return ret;
+   time = rtc_tm_to_time64(tm);
+   writel_relaxed(time, info->rcnr);
+
+   return 0;
 }
 
 static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
@@ -185,13 +184,11 @@ static int sa1100_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
 static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
struct sa1100_rtc *info = dev_get_drvdata(dev);
-   unsigned long time;
-   int ret;
+   unsigned long long time;
 
spin_lock_irq(>lock);
-   ret = rtc_tm_to_time(>time, );
-   if (ret != 0)
-   goto out;
+   time = rtc_tm_to_time64(>time);
+
writel_relaxed(readl_relaxed(info->rtsr) &
(RTSR_HZE | RTSR_ALE | RTSR_AL), info->rtsr);
writel_relaxed(time, info->rtar);
@@ -199,10 +196,10 @@ static int sa1100_rtc_set_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
writel_relaxed(readl_relaxed(info->rtsr) | RTSR_ALE, 
info->rtsr);
else
writel_relaxed(readl_relaxed(info->rtsr) & ~RTSR_ALE, 
info->rtsr);
-out:
+
spin_unlock_irq(>lock);
 
-   return ret;
+   return 0;
 }
 
 static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)
-- 
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.


[rtc-linux] [PATCH 41/51] rtc: stk17ta8: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-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;
 }
-- 
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.


[rtc-linux] [PATCH 38/51] rtc: sh: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-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, ) < 0) {
-   rtc_time_to_tm(0, );
+   rtc_time64_to_tm(0, );
rtc_set_time(rtc->rtc_dev, );
}
 
-- 
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.


[rtc-linux] [PATCH 45/51] rtc: tegra stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Thierry Reding <thierry.red...@gmail.com>
CC: Jonathan Hunter <jonath...@nvidia.com>
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
CC: linux-te...@vger.kernel.org
---
 drivers/rtc/rtc-tegra.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index d30d57b..a429884 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -110,7 +110,7 @@ static int tegra_rtc_wait_while_busy(struct device *dev)
 static int tegra_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
struct tegra_rtc_info *info = dev_get_drvdata(dev);
-   unsigned long sec, msec;
+   unsigned long long sec, msec;
unsigned long sl_irq_flags;
 
/* RTC hardware copies seconds to shadow seconds when a read
@@ -122,9 +122,9 @@ static int tegra_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 
spin_unlock_irqrestore(>tegra_rtc_lock, sl_irq_flags);
 
-   rtc_time_to_tm(sec, tm);
+   rtc_time64_to_tm(sec, tm);
 
-   dev_vdbg(dev, "time read as %lu. %d/%d/%d %d:%02u:%02u\n",
+   dev_vdbg(dev, "time read as %llu. %d/%d/%d %d:%02u:%02u\n",
sec,
tm->tm_mon + 1,
tm->tm_mday,
@@ -140,7 +140,7 @@ static int tegra_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 static int tegra_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
struct tegra_rtc_info *info = dev_get_drvdata(dev);
-   unsigned long sec;
+   unsigned long long sec;
int ret;
 
/* convert tm to seconds. */
@@ -148,9 +148,9 @@ static int tegra_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
if (ret)
return ret;
 
-   rtc_tm_to_time(tm, );
+   sec = rtc_tm_to_time64(tm);
 
-   dev_vdbg(dev, "time set to %lu. %d/%d/%d %d:%02u:%02u\n",
+   dev_vdbg(dev, "time set to %llu. %d/%d/%d %d:%02u:%02u\n",
sec,
tm->tm_mon+1,
tm->tm_mday,
@@ -174,7 +174,7 @@ static int tegra_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
 static int tegra_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
struct tegra_rtc_info *info = dev_get_drvdata(dev);
-   unsigned long sec;
+   unsigned long long sec;
unsigned tmp;
 
sec = readl(info->rtc_base + TEGRA_RTC_REG_SECONDS_ALARM0);
@@ -185,7 +185,7 @@ static int tegra_rtc_read_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
} else {
/* alarm is enabled. */
alarm->enabled = 1;
-   rtc_time_to_tm(sec, >time);
+   rtc_time64_to_tm(sec, >time);
}
 
tmp = readl(info->rtc_base + TEGRA_RTC_REG_INTR_STATUS);
@@ -220,10 +220,10 @@ static int tegra_rtc_alarm_irq_enable(struct device *dev, 
unsigned int enabled)
 static int tegra_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
struct tegra_rtc_info *info = dev_get_drvdata(dev);
-   unsigned long sec;
+   unsigned long long sec;
 
if (alarm->enabled)
-   rtc_tm_to_time(>time, );
+   sec = rtc_tm_to_time64(>time);
else
sec = 0;
 
@@ -236,7 +236,7 @@ static int tegra_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
if (sec) {
tegra_rtc_alarm_irq_enable(dev, 1);
 
-   dev_vdbg(dev, "alarm set as %lu. %d/%d/%d %d:%02u:%02u\n",
+   dev_vdbg(dev, "alarm set as %llu. %d/%d/%d %d:%02u:%02u\n",
sec,
alarm->time.tm_mon+1,
alarm->time.tm_mday,
-- 
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.


[rtc-linux] [PATCH 42/51] rtc: stmp3xxx: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.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-stmp3xxx.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index d578e40..0f7cedc 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -160,11 +160,11 @@ static int stmp3xxx_rtc_gettime(struct device *dev, 
struct rtc_time *rtc_tm)
if (ret)
return ret;
 
-   rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm);
+   rtc_time64_to_tm(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm);
return 0;
 }
 
-static int stmp3xxx_rtc_set_mmss(struct device *dev, unsigned long t)
+static int stmp3xxx_rtc_set_mmss64(struct device *dev, time64_t t)
 {
struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
 
@@ -214,16 +214,16 @@ static int stmp3xxx_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alm)
 {
struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
 
-   rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_ALARM), >time);
+   rtc_time64_to_tm(readl(rtc_data->io + STMP3XXX_RTC_ALARM), >time);
return 0;
 }
 
 static int stmp3xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
 {
-   unsigned long t;
+   unsigned long long t;
struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
 
-   rtc_tm_to_time(>time, );
+   t = rtc_tm_to_time64(>time);
writel(t, rtc_data->io + STMP3XXX_RTC_ALARM);
 
stmp3xxx_alarm_irq_enable(dev, alm->enabled);
@@ -235,7 +235,7 @@ static int stmp3xxx_rtc_set_alarm(struct device *dev, 
struct rtc_wkalrm *alm)
.alarm_irq_enable =
  stmp3xxx_alarm_irq_enable,
.read_time  = stmp3xxx_rtc_gettime,
-   .set_mmss   = stmp3xxx_rtc_set_mmss,
+   .set_mmss64 = stmp3xxx_rtc_set_mmss64,
.read_alarm = stmp3xxx_rtc_read_alarm,
.set_alarm  = stmp3xxx_rtc_set_alarm,
 };
-- 
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.


[rtc-linux] [PATCH 36/51] rtc: rs5c348: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-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(>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(>dev, "voltage-low detected.\n");
if (ret & RS5C348_BIT_XSTP)
dev_warn(>dev, "oscillator-stop detected.\n");
-   rtc_time_to_tm(0, ); /* 1970/1/1 */
+   rtc_time64_to_tm(0, );   /* 1970/1/1 */
ret = rs5c348_rtc_set_time(>dev, );
if (ret < 0)
goto kfree_exit;
-- 
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.


[rtc-linux] [PATCH 32/51] rtc: pcap: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-pcap.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c
index c443324..fbd2cd6 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 = >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, );
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
 
-   rtc_time_to_tm(secs, tm);
+   rtc_time64_to_tm(secs, tm);
 
return 0;
 }
@@ -66,10 +66,10 @@ 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 = >time;
-   unsigned long secs;
+   unsigned long long secs;
u32 tod, days;
 
-   rtc_tm_to_time(tm, );
+   secs = rtc_tm_to_time64(tm);
 
tod = secs % SEC_PER_DAY;
ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod);
@@ -84,7 +84,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, );
@@ -93,12 +93,12 @@ static int pcap_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, );
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);
@@ -135,7 +135,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,
 };
 
-- 
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.


[rtc-linux] [PATCH 28/51] rtc: jz4740: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.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-jz4740.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
index 64989af..7ce1f43 100644
--- a/drivers/rtc/rtc-jz4740.c
+++ b/drivers/rtc/rtc-jz4740.c
@@ -171,12 +171,12 @@ static int jz4740_rtc_read_time(struct device *dev, 
struct rtc_time *time)
if (timeout == 0)
return -EIO;
 
-   rtc_time_to_tm(secs, time);
+   rtc_time64_to_tm((u64)secs, time);
 
return rtc_valid_tm(time);
 }
 
-static int jz4740_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int jz4740_rtc_set_mmss64(struct device *dev, time64_t secs)
 {
struct jz4740_rtc *rtc = dev_get_drvdata(dev);
 
@@ -196,7 +196,7 @@ static int jz4740_rtc_read_alarm(struct device *dev, struct 
rtc_wkalrm *alrm)
alrm->enabled = !!(ctrl & JZ_RTC_CTRL_AE);
alrm->pending = !!(ctrl & JZ_RTC_CTRL_AF);
 
-   rtc_time_to_tm(secs, >time);
+   rtc_time64_to_tm((u64)secs, >time);
 
return rtc_valid_tm(>time);
 }
@@ -205,9 +205,9 @@ static int jz4740_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 {
int ret;
struct jz4740_rtc *rtc = dev_get_drvdata(dev);
-   unsigned long secs;
+   unsigned long long secs;
 
-   rtc_tm_to_time(>time, );
+   secs = rtc_tm_to_time64(>time);
 
ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC_ALARM, secs);
if (!ret)
@@ -225,7 +225,7 @@ static int jz4740_rtc_alarm_irq_enable(struct device *dev, 
unsigned int enable)
 
 static const struct rtc_class_ops jz4740_rtc_ops = {
.read_time  = jz4740_rtc_read_time,
-   .set_mmss   = jz4740_rtc_set_mmss,
+   .set_mmss64 = jz4740_rtc_set_mmss64,
.read_alarm = jz4740_rtc_read_alarm,
.set_alarm  = jz4740_rtc_set_alarm,
.alarm_irq_enable = jz4740_rtc_alarm_irq_enable,
-- 
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.


[rtc-linux] [PATCH 31/51] rtc: omap: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.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-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, );
bcd2tm();
-   rtc_tm_to_time(, );
-   rtc_time_to_tm(now + 2, );
+   now = rtc_tm_to_time64();
+   rtc_time64_to_tm(now + 2, );
 
if (tm2bcd() < 0) {
dev_err(>rtc->dev, "power off failed\n");
-- 
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.


[rtc-linux] [PATCH 51/51] power: suspend test: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: "Rafael J. Wysocki" <r...@rjwysocki.net>
CC: Pavel Machek <pa...@ucw.cz>
CC: Len Brown <len.br...@intel.com>
CC: Alessandro Zummo <a.zu...@towertech.it>
CC: Alexandre Belloni <alexandre.bell...@free-electrons.com>
CC: rtc-linux@googlegroups.com
CC: linux...@vger.kernel.org
CC: linux-ker...@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(>dev), status);
return;
}
-   rtc_tm_to_time(, );
+   now = rtc_tm_to_time64();
 
memset(, 0, sizeof alm);
-   rtc_time_to_tm(now + TEST_SUSPEND_SECONDS, );
+   rtc_time64_to_tm(now + TEST_SUSPEND_SECONDS, );
alm.enabled = true;
 
status = rtc_set_alarm(rtc, );
-- 
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.


[rtc-linux] [PATCH 48/51] rtc: vr41xx: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-vr41xx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index e1b86bb..db51ed6 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -138,12 +138,12 @@ static void vr41xx_rtc_release(struct device *dev)
 
 static int vr41xx_rtc_read_time(struct device *dev, struct rtc_time *time)
 {
-   unsigned long epoch_sec, elapsed_sec;
+   unsigned long long epoch_sec, elapsed_sec;
 
epoch_sec = mktime(epoch, 1, 1, 0, 0, 0);
elapsed_sec = read_elapsed_second();
 
-   rtc_time_to_tm(epoch_sec + elapsed_sec, time);
+   rtc_time64_to_tm(epoch_sec + elapsed_sec, time);
 
return 0;
 }
@@ -175,7 +175,7 @@ static int vr41xx_rtc_read_alarm(struct device *dev, struct 
rtc_wkalrm *wkalrm)
 
spin_unlock_irq(_lock);
 
-   rtc_time_to_tm((high << 17) | (mid << 1) | (low >> 15), time);
+   rtc_time64_to_tm((high << 17) | (mid << 1) | (low >> 15), time);
 
return 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.


[rtc-linux] [PATCH 34/51] rtc: pl031: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Linus Walleij <linus.wall...@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
CC: linux-arm-ker...@lists.infradead.org
---
 drivers/rtc/rtc-pl031.c | 31 +--
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index e1687e1..07f72b3 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -127,11 +127,11 @@ static int pl031_stv2_tm_to_time(struct device *dev,
return -EINVAL;
} else if (wday == -1) {
/* wday is not provided, calculate it here */
-   unsigned long time;
+   unsigned long long time;
struct rtc_time calc_tm;
 
-   rtc_tm_to_time(tm, );
-   rtc_time_to_tm(time, _tm);
+   time = rtc_tm_to_time64(tm);
+   rtc_time64_to_tm(time, _tm);
wday = calc_tm.tm_wday;
}
 
@@ -252,30 +252,27 @@ static int pl031_read_time(struct device *dev, struct 
rtc_time *tm)
 {
struct pl031_local *ldata = dev_get_drvdata(dev);
 
-   rtc_time_to_tm(readl(ldata->base + RTC_DR), tm);
+   rtc_time64_to_tm(readl(ldata->base + RTC_DR), tm);
 
return 0;
 }
 
 static int pl031_set_time(struct device *dev, struct rtc_time *tm)
 {
-   unsigned long time;
+   unsigned long long time;
struct pl031_local *ldata = dev_get_drvdata(dev);
-   int ret;
-
-   ret = rtc_tm_to_time(tm, );
 
-   if (ret == 0)
-   writel(time, ldata->base + RTC_LR);
+   time = rtc_tm_to_time64(tm);
+   writel(time, ldata->base + RTC_LR);
 
-   return ret;
+   return 0;
 }
 
 static int pl031_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
struct pl031_local *ldata = dev_get_drvdata(dev);
 
-   rtc_time_to_tm(readl(ldata->base + RTC_MR), >time);
+   rtc_time64_to_tm(readl(ldata->base + RTC_MR), >time);
 
alarm->pending = readl(ldata->base + RTC_RIS) & RTC_BIT_AI;
alarm->enabled = readl(ldata->base + RTC_IMSC) & RTC_BIT_AI;
@@ -286,17 +283,15 @@ static int pl031_read_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
 static int pl031_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
struct pl031_local *ldata = dev_get_drvdata(dev);
-   unsigned long time;
+   unsigned long long time;
int ret;
 
/* At the moment, we can only deal with non-wildcarded alarm times. */
ret = rtc_valid_tm(>time);
if (ret == 0) {
-   ret = rtc_tm_to_time(>time, );
-   if (ret == 0) {
-   writel(time, ldata->base + RTC_MR);
-   pl031_alarm_irq_enable(dev, alarm->enabled);
-   }
+   time = rtc_tm_to_time64(>time);
+   writel(time, ldata->base + RTC_MR);
+   pl031_alarm_irq_enable(dev, alarm->enabled);
}
 
return ret;
-- 
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.


[rtc-linux] [PATCH 49/51] rtc: wm831x: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.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
CC: patc...@opensource.wolfsonmicro.com
---
 drivers/rtc/rtc-wm831x.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c
index 75aea4c..e42b07c 100644
--- a/drivers/rtc/rtc-wm831x.c
+++ b/drivers/rtc/rtc-wm831x.c
@@ -153,9 +153,9 @@ static int wm831x_rtc_readtime(struct device *dev, struct 
rtc_time *tm)
continue;
 
if (memcmp(time1, time2, sizeof(time1)) == 0) {
-   u32 time = (time1[0] << 16) | time1[1];
+   u64 time = (time1[0] << 16) | time1[1];
 
-   rtc_time_to_tm(time, tm);
+   rtc_time64_to_tm(time, tm);
return rtc_valid_tm(tm);
}
 
@@ -169,12 +169,12 @@ static int wm831x_rtc_readtime(struct device *dev, struct 
rtc_time *tm)
 /*
  * Set current time and date in RTC
  */
-static int wm831x_rtc_set_mmss(struct device *dev, unsigned long time)
+static int wm831x_rtc_set_mmss64(struct device *dev, time64_t time)
 {
struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev);
struct wm831x *wm831x = wm831x_rtc->wm831x;
struct rtc_time new_tm;
-   unsigned long new_time;
+   unsigned long long new_time;
int ret;
int count = 0;
 
@@ -215,11 +215,7 @@ static int wm831x_rtc_set_mmss(struct device *dev, 
unsigned long time)
if (ret < 0)
return ret;
 
-   ret = rtc_tm_to_time(_tm, _time);
-   if (ret < 0) {
-   dev_err(dev, "Failed to convert time: %d\n", ret);
-   return ret;
-   }
+   new_time = rtc_tm_to_time64(_tm);
 
/* Allow a second of change in case of tick */
if (new_time - time > 1) {
@@ -238,7 +234,7 @@ static int wm831x_rtc_readalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev);
int ret;
u16 data[2];
-   u32 time;
+   u64 time;
 
ret = wm831x_bulk_read(wm831x_rtc->wm831x, WM831X_RTC_ALARM_1,
   2, data);
@@ -249,7 +245,7 @@ static int wm831x_rtc_readalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 
time = (data[0] << 16) | data[1];
 
-   rtc_time_to_tm(time, >time);
+   rtc_time64_to_tm(time, >time);
 
ret = wm831x_reg_read(wm831x_rtc->wm831x, WM831X_RTC_CONTROL);
if (ret < 0) {
@@ -286,13 +282,9 @@ static int wm831x_rtc_setalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev);
struct wm831x *wm831x = wm831x_rtc->wm831x;
int ret;
-   unsigned long time;
+   unsigned long long time;
 
-   ret = rtc_tm_to_time(>time, );
-   if (ret < 0) {
-   dev_err(dev, "Failed to convert time: %d\n", ret);
-   return ret;
-   }
+   time = rtc_tm_to_time64(>time);
 
ret = wm831x_rtc_stop_alarm(wm831x_rtc);
if (ret < 0) {
@@ -346,7 +338,7 @@ static irqreturn_t wm831x_alm_irq(int irq, void *data)
 
 static const struct rtc_class_ops wm831x_rtc_ops = {
.read_time = wm831x_rtc_readtime,
-   .set_mmss = wm831x_rtc_set_mmss,
+   .set_mmss64 = wm831x_rtc_set_mmss64,
.read_alarm = wm831x_rtc_readalarm,
.set_alarm = wm831x_rtc_setalarm,
.alarm_irq_enable = wm831x_rtc_alarm_irq_enable,
-- 
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.


[rtc-linux] [PATCH 29/51] rtc: lpc32xx: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.gaign...@linaro.org>
CC: Vladimir Zapolskiy <v...@mleia.com>
CC: Sylvain Lemieux <slemieux.t...@gmail.com>
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
CC: linux-arm-ker...@lists.infradead.org
---
 drivers/rtc/rtc-lpc32xx.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c
index 887871c..a3f5233 100644
--- a/drivers/rtc/rtc-lpc32xx.c
+++ b/drivers/rtc/rtc-lpc32xx.c
@@ -64,16 +64,16 @@ struct lpc32xx_rtc {
 
 static int lpc32xx_rtc_read_time(struct device *dev, struct rtc_time *time)
 {
-   unsigned long elapsed_sec;
+   unsigned long long elapsed_sec;
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
 
elapsed_sec = rtc_readl(rtc, LPC32XX_RTC_UCOUNT);
-   rtc_time_to_tm(elapsed_sec, time);
+   rtc_time64_to_tm(elapsed_sec, time);
 
return rtc_valid_tm(time);
 }
 
-static int lpc32xx_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int lpc32xx_rtc_set_mmss64(struct device *dev, time64_t secs)
 {
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
u32 tmp;
@@ -97,7 +97,7 @@ static int lpc32xx_rtc_read_alarm(struct device *dev,
 {
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
 
-   rtc_time_to_tm(rtc_readl(rtc, LPC32XX_RTC_MATCH0), >time);
+   rtc_time64_to_tm(rtc_readl(rtc, LPC32XX_RTC_MATCH0), >time);
wkalrm->enabled = rtc->alarm_enabled;
wkalrm->pending = !!(rtc_readl(rtc, LPC32XX_RTC_INTSTAT) &
LPC32XX_RTC_INTSTAT_MATCH0);
@@ -109,15 +109,10 @@ static int lpc32xx_rtc_set_alarm(struct device *dev,
struct rtc_wkalrm *wkalrm)
 {
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
-   unsigned long alarmsecs;
+   unsigned long long alarmsecs;
u32 tmp;
-   int ret;
 
-   ret = rtc_tm_to_time(>time, );
-   if (ret < 0) {
-   dev_warn(dev, "Failed to convert time: %d\n", ret);
-   return ret;
-   }
+   alarmsecs = rtc_tm_to_time64(>time);
 
spin_lock_irq(>lock);
 
@@ -191,7 +186,7 @@ static irqreturn_t lpc32xx_rtc_alarm_interrupt(int irq, 
void *dev)
 
 static const struct rtc_class_ops lpc32xx_rtc_ops = {
.read_time  = lpc32xx_rtc_read_time,
-   .set_mmss   = lpc32xx_rtc_set_mmss,
+   .set_mmss64 = lpc32xx_rtc_set_mmss64,
.read_alarm = lpc32xx_rtc_read_alarm,
.set_alarm  = lpc32xx_rtc_set_alarm,
.alarm_irq_enable   = lpc32xx_rtc_alarm_irq_enable,
-- 
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.


[rtc-linux] [PATCH 23/51] rtc: ds1672: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.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-ds1672.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index 7bf46bf..ff2468c 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -30,7 +30,7 @@
  */
 static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm)
 {
-   unsigned long time;
+   unsigned long long time;
unsigned char addr = DS1672_REG_CNT_BASE;
unsigned char buf[4];
 
@@ -60,7 +60,7 @@ static int ds1672_get_datetime(struct i2c_client *client, 
struct rtc_time *tm)
 
time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
 
-   rtc_time_to_tm(time, tm);
+   rtc_time64_to_tm(time, tm);
 
dev_dbg(>dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
"mday=%d, mon=%d, year=%d, wday=%d\n",
@@ -96,7 +96,7 @@ static int ds1672_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
return ds1672_get_datetime(to_i2c_client(dev), tm);
 }
 
-static int ds1672_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int ds1672_rtc_set_mmss64(struct device *dev, time64_t secs)
 {
return ds1672_set_mmss(to_i2c_client(dev), secs);
 }
@@ -148,7 +148,7 @@ static ssize_t show_control(struct device *dev, struct 
device_attribute *attr,
 
 static const struct rtc_class_ops ds1672_rtc_ops = {
.read_time = ds1672_rtc_read_time,
-   .set_mmss = ds1672_rtc_set_mmss,
+   .set_mmss64 = ds1672_rtc_set_mmss64,
 };
 
 static int ds1672_probe(struct i2c_client *client,
-- 
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.


[rtc-linux] [PATCH 11/51] rtc: bfin: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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
CC: adi-buildroot-de...@lists.sourceforge.net
---
 drivers/rtc/rtc-bfin.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index 15344b7..4c79bd0 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -103,7 +103,7 @@ static inline unsigned long rtc_bfin_to_time(u32 rtc_bfin)
 }
 static inline void rtc_bfin_to_tm(u32 rtc_bfin, struct rtc_time *tm)
 {
-   rtc_time_to_tm(rtc_bfin_to_time(rtc_bfin), tm);
+   rtc_time64_to_tm(rtc_bfin_to_time(rtc_bfin), tm);
 }
 
 /**
@@ -271,20 +271,17 @@ static int bfin_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 static int bfin_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
struct bfin_rtc *rtc = dev_get_drvdata(dev);
-   int ret;
-   unsigned long now;
+   unsigned long long now;
 
dev_dbg_stamp(dev);
 
-   ret = rtc_tm_to_time(tm, );
-   if (ret == 0) {
-   if (rtc->rtc_wrote_regs & 0x1)
-   bfin_rtc_sync_pending(dev);
-   bfin_write_RTC_STAT(rtc_time_to_bfin(now));
-   rtc->rtc_wrote_regs = 0x1;
-   }
+   now = rtc_tm_to_time64(tm);
+   if (rtc->rtc_wrote_regs & 0x1)
+   bfin_rtc_sync_pending(dev);
+   bfin_write_RTC_STAT(rtc_time_to_bfin(now));
+   rtc->rtc_wrote_regs = 0x1;
 
-   return ret;
+   return 0;
 }
 
 static int bfin_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
@@ -300,12 +297,11 @@ static int bfin_rtc_read_alarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 static int bfin_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
struct bfin_rtc *rtc = dev_get_drvdata(dev);
-   unsigned long rtc_alarm;
+   unsigned long long rtc_alarm;
 
dev_dbg_stamp(dev);
 
-   if (rtc_tm_to_time(>time, _alarm))
-   return -EINVAL;
+   rtc_alarm = rtc_tm_to_time64(>time);
 
rtc->rtc_alarm = alrm->time;
 
-- 
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.


[rtc-linux] [PATCH 26/51] rtc: gemini: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Hans Ulli Kroll <ulli.kr...@googlemail.com>
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
CC: linux-arm-ker...@lists.infradead.org
---
 drivers/rtc/rtc-gemini.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-gemini.c b/drivers/rtc/rtc-gemini.c
index 5279390..222f144 100644
--- a/drivers/rtc/rtc-gemini.c
+++ b/drivers/rtc/rtc-gemini.c
@@ -71,7 +71,7 @@ static int gemini_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
struct gemini_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 + GEMINI_RTC_SECOND);
min  = readl(rtc->rtc_base + GEMINI_RTC_MINUTE);
@@ -81,7 +81,7 @@ static int gemini_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;
 }
@@ -90,12 +90,12 @@ static int gemini_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
 {
struct gemini_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 = rtc_tm_to_time64(tm);
 
sec = readl(rtc->rtc_base + GEMINI_RTC_SECOND);
min = readl(rtc->rtc_base + GEMINI_RTC_MINUTE);
-- 
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.


[rtc-linux] [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Support Opensource <support.opensou...@diasemi.com>
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-da9052.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
index 4273377..99a0489 100644
--- a/drivers/rtc/rtc-da9052.c
+++ b/drivers/rtc/rtc-da9052.c
@@ -104,17 +104,15 @@ static int da9052_read_alarm(struct da9052_rtc *rtc, 
struct rtc_time *rtc_tm)
 static int da9052_set_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm)
 {
struct da9052 *da9052 = rtc->da9052;
-   unsigned long alm_time;
+   unsigned long long alm_time;
int ret;
uint8_t v[3];
 
-   ret = rtc_tm_to_time(rtc_tm, _time);
-   if (ret != 0)
-   return ret;
+   alm_time = rtc_tm_to_time64(rtc_tm);
 
if (rtc_tm->tm_sec > 0) {
alm_time += 60 - rtc_tm->tm_sec;
-   rtc_time_to_tm(alm_time, rtc_tm);
+   rtc_time64_to_tm(alm_time, rtc_tm);
}
BUG_ON(rtc_tm->tm_sec); /* it will cause repeated irqs if not zero */
 
-- 
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.


[rtc-linux] [PATCH 10/51] rtc: at91sam9: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-at91sam9.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 7418a76..be1f37e 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -122,7 +122,7 @@ static int at91_rtc_readtime(struct device *dev, struct 
rtc_time *tm)
if (secs != secs2)
secs = rtt_readl(rtc, VR);
 
-   rtc_time_to_tm(offset + secs, tm);
+   rtc_time64_to_tm((u64)(offset + secs), tm);
 
dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "readtime",
1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
@@ -137,17 +137,14 @@ static int at91_rtc_readtime(struct device *dev, struct 
rtc_time *tm)
 static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
 {
struct sam9_rtc *rtc = dev_get_drvdata(dev);
-   int err;
u32 offset, alarm, mr;
-   unsigned long secs;
+   unsigned long long secs;
 
dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "settime",
1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
 
-   err = rtc_tm_to_time(tm, );
-   if (err != 0)
-   return err;
+   secs = rtc_tm_to_time64(tm);
 
mr = rtt_readl(rtc, MR);
 
@@ -197,7 +194,7 @@ static int at91_rtc_readalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 
memset(alrm, 0, sizeof(*alrm));
if (alarm != ALARM_DISABLED && offset != 0) {
-   rtc_time_to_tm(offset + alarm, tm);
+   rtc_time64_to_tm((u64)(offset + alarm), tm);
 
dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "readalarm",
1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
@@ -214,14 +211,11 @@ static int at91_rtc_setalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 {
struct sam9_rtc *rtc = dev_get_drvdata(dev);
struct rtc_time *tm = >time;
-   unsigned long secs;
+   unsigned long long secs;
u32 offset;
u32 mr;
-   int err;
 
-   err = rtc_tm_to_time(tm, );
-   if (err != 0)
-   return err;
+   secs = rtc_tm_to_time64(tm);
 
offset = gpbr_readl(rtc);
if (offset == 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.


[rtc-linux] [PATCH 24/51] rtc: ds2404: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.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-ds2404.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-ds2404.c b/drivers/rtc/rtc-ds2404.c
index 9a1582e..b7d04a7 100644
--- a/drivers/rtc/rtc-ds2404.c
+++ b/drivers/rtc/rtc-ds2404.c
@@ -201,16 +201,16 @@ static void ds2404_enable_osc(struct device *dev)
 
 static int ds2404_read_time(struct device *dev, struct rtc_time *dt)
 {
-   unsigned long time = 0;
+   unsigned long long time = 0;
 
ds2404_read_memory(dev, 0x203, 4, (u8 *));
time = le32_to_cpu(time);
 
-   rtc_time_to_tm(time, dt);
+   rtc_time64_to_tm(time, dt);
return rtc_valid_tm(dt);
 }
 
-static int ds2404_set_mmss(struct device *dev, unsigned long secs)
+static int ds2404_set_mmss64(struct device *dev, time64_t secs)
 {
u32 time = cpu_to_le32(secs);
ds2404_write_memory(dev, 0x203, 4, (u8 *));
@@ -219,7 +219,7 @@ static int ds2404_set_mmss(struct device *dev, unsigned 
long secs)
 
 static const struct rtc_class_ops ds2404_rtc_ops = {
.read_time  = ds2404_read_time,
-   .set_mmss   = ds2404_set_mmss,
+   .set_mmss64 = ds2404_set_mmss64,
 };
 
 static int rtc_probe(struct platform_device *pdev)
-- 
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.


[rtc-linux] [PATCH 20/51] rtc: ds1374: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-ds1374.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 38a2e9e..624b915 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -164,7 +164,7 @@ static int ds1374_read_time(struct device *dev, struct 
rtc_time *time)
 
ret = ds1374_read_rtc(client, , DS1374_REG_TOD0, 4);
if (!ret)
-   rtc_time_to_tm(itime, time);
+   rtc_time64_to_tm((u64)itime, time);
 
return ret;
 }
@@ -172,9 +172,9 @@ static int ds1374_read_time(struct device *dev, struct 
rtc_time *time)
 static int ds1374_set_time(struct device *dev, struct rtc_time *time)
 {
struct i2c_client *client = to_i2c_client(dev);
-   unsigned long itime;
+   unsigned long long itime;
 
-   rtc_tm_to_time(time, );
+   itime = rtc_tm_to_time64(time);
return ds1374_write_rtc(client, itime, DS1374_REG_TOD0, 4);
 }
 
-- 
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.


[rtc-linux] [PATCH 21/51] rtc: ds1511: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-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;
 }
-- 
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.


[rtc-linux] [PATCH 22/51] rtc: ds1553: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-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;
 }
-- 
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.


[rtc-linux] [PATCH 09/51] rtc: at32ap700x: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-at32ap700x.c | 29 -
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c
index de8bf56..db58cf5 100644
--- a/drivers/rtc/rtc-at32ap700x.c
+++ b/drivers/rtc/rtc-at32ap700x.c
@@ -61,7 +61,7 @@
 struct rtc_at32ap700x {
struct rtc_device   *rtc;
void __iomem*regs;
-   unsigned long   alarm_time;
+   unsigned long long  alarm_time;
unsigned long   irq;
/* Protect against concurrent register access. */
spinlock_t  lock;
@@ -70,10 +70,10 @@ struct rtc_at32ap700x {
 static int at32_rtc_readtime(struct device *dev, struct rtc_time *tm)
 {
struct rtc_at32ap700x *rtc = dev_get_drvdata(dev);
-   unsigned long now;
+   unsigned long long now;
 
now = rtc_readl(rtc, VAL);
-   rtc_time_to_tm(now, tm);
+   rtc_time64_to_tm(now, tm);
 
return 0;
 }
@@ -81,14 +81,12 @@ static int at32_rtc_readtime(struct device *dev, struct 
rtc_time *tm)
 static int at32_rtc_settime(struct device *dev, struct rtc_time *tm)
 {
struct rtc_at32ap700x *rtc = dev_get_drvdata(dev);
-   unsigned long now;
-   int ret;
+   unsigned long long now;
 
-   ret = rtc_tm_to_time(tm, );
-   if (ret == 0)
-   rtc_writel(rtc, VAL, now);
+   now = rtc_tm_to_time64(tm);
+   rtc_writel(rtc, VAL, now);
 
-   return ret;
+   return 0;
 }
 
 static int at32_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
@@ -96,7 +94,7 @@ static int at32_rtc_readalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
struct rtc_at32ap700x *rtc = dev_get_drvdata(dev);
 
spin_lock_irq(>lock);
-   rtc_time_to_tm(rtc->alarm_time, >time);
+   rtc_time64_to_tm(rtc->alarm_time, >time);
alrm->enabled = rtc_readl(rtc, IMR) & RTC_BIT(IMR_TOPI) ? 1 : 0;
alrm->pending = rtc_readl(rtc, ISR) & RTC_BIT(ISR_TOPI) ? 1 : 0;
spin_unlock_irq(>lock);
@@ -107,15 +105,12 @@ static int at32_rtc_readalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 static int at32_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
struct rtc_at32ap700x *rtc = dev_get_drvdata(dev);
-   unsigned long rtc_unix_time;
-   unsigned long alarm_unix_time;
-   int ret;
+   unsigned long long rtc_unix_time;
+   unsigned long long alarm_unix_time;
 
rtc_unix_time = rtc_readl(rtc, VAL);
 
-   ret = rtc_tm_to_time(>time, _unix_time);
-   if (ret)
-   return ret;
+   alarm_unix_time = rtc_tm_to_time64(>time);
 
if (alarm_unix_time < rtc_unix_time)
return -EINVAL;
@@ -131,7 +126,7 @@ static int at32_rtc_setalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
& ~RTC_BIT(CTRL_TOPEN));
spin_unlock_irq(>lock);
 
-   return ret;
+   return 0;
 }
 
 static int at32_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
-- 
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.


[rtc-linux] [PATCH 17/51] rtc: digicolor: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Baruch Siach <bar...@tkos.co.il>
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
CC: linux-arm-ker...@lists.infradead.org
---
 drivers/rtc/rtc-digicolor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-digicolor.c b/drivers/rtc/rtc-digicolor.c
index b253bf1..01b0fe8 100644
--- a/drivers/rtc/rtc-digicolor.c
+++ b/drivers/rtc/rtc-digicolor.c
@@ -106,7 +106,7 @@ static int dc_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
return 0;
 }
 
-static int dc_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int dc_rtc_set_mmss64(struct device *dev, time64_t secs)
 {
struct dc_rtc *rtc = dev_get_drvdata(dev);
 
@@ -161,7 +161,7 @@ static int dc_rtc_alarm_irq_enable(struct device *dev, 
unsigned int enabled)
 
 static const struct rtc_class_ops dc_rtc_ops = {
.read_time  = dc_rtc_read_time,
-   .set_mmss   = dc_rtc_set_mmss,
+   .set_mmss64 = dc_rtc_set_mmss64,
.read_alarm = dc_rtc_read_alarm,
.set_alarm  = dc_rtc_set_alarm,
.alarm_irq_enable   = dc_rtc_alarm_irq_enable,
-- 
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.


[rtc-linux] [PATCH 16/51] rtc: davinci: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-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, );
-   rtc_tm_to_time(, );
+   now = rtc_tm_to_time64();
 
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(>time, );
+   then = rtc_tm_to_time64(>time);
 
if (then < now) {
-   rtc_time_to_tm(now + 24 * 60 * 60, );
+   rtc_time64_to_tm(now + 24 * 60 * 60, );
alm->time.tm_mday = tm.tm_mday;
alm->time.tm_mon = tm.tm_mon;
alm->time.tm_year = tm.tm_year;
-- 
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.


[rtc-linux] [PATCH 07/51] rtc: ab8500: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Linus Walleij <linus.wall...@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
CC: linux-arm-ker...@lists.infradead.org
---
 drivers/rtc/rtc-ab8500.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 24a0af6..ac131bd 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(, );
+   secs = rtc_tm_to_time64();
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, no_mins, 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 = rtc_tm_to_time64(tm);
 
/*
 * Convert it to the number of seconds since 01-01-2000 00:00:00, since
@@ -185,7 +185,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 +214,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, >time);
+   rtc_time64_to_tm(secs, >time);
 
return rtc_valid_tm(>time);
 }
@@ -230,7 +230,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 mins, secs = 0, cursec = 0;
struct rtc_time curtm;
 
if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) {
@@ -240,7 +240,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(>time, );
+   secs = rtc_tm_to_time64(>time);
 
/*
 * Check whether alarm is set less than 1min.
@@ -248,7 +248,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, ); /* Read current time */
-   rtc_tm_to_time(, );
+   cursec = rtc_tm_to_time64();
if ((secs - cursec) < 59) {
dev_dbg(dev, "Alarm less than 1 minute not supported\r\n");
return -EINVAL;
@@ -281,7 +281,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 mins, secs = 0;
 
if (

[rtc-linux] [PATCH 18/51] rtc: dm355evm: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-dm355evm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c
index f225cd8..34544b6 100644
--- a/drivers/rtc/rtc-dm355evm.c
+++ b/drivers/rtc/rtc-dm355evm.c
@@ -78,17 +78,17 @@ static int dm355evm_rtc_read_time(struct device *dev, 
struct rtc_time *tm)
 
dev_dbg(dev, "read timestamp %08x\n", time.value);
 
-   rtc_time_to_tm(le32_to_cpu(time.value), tm);
+   rtc_time64_to_tm(le32_to_cpu(time.value), tm);
return 0;
 }
 
 static int dm355evm_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
union evm_time  time;
-   unsigned long   value;
+   unsigned long long value;
int status;
 
-   rtc_tm_to_time(tm, );
+   value = rtc_tm_to_time64(tm);
time.value = cpu_to_le32(value);
 
dev_dbg(dev, "write timestamp %08x\n", time.value);
-- 
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.


[rtc-linux] [PATCH 13/51] rtc: cpcap: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-cpcap.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c
index 3a0333e..059aa18 100644
--- a/drivers/rtc/rtc-cpcap.c
+++ b/drivers/rtc/rtc-cpcap.c
@@ -58,19 +58,19 @@ 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;
 
-   rtc_tm_to_time(rtc, );
+   time = rtc_tm_to_time64(rtc);
 
cpcap->day = time / SECS_PER_DAY;
time %= SECS_PER_DAY;
-- 
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.


[rtc-linux] [PATCH 05/51] rtc: 88pm860x: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-88pm860x.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
index 19e53b3..0d20ede 100644
--- a/drivers/rtc/rtc-88pm860x.c
+++ b/drivers/rtc/rtc-88pm860x.c
@@ -86,8 +86,8 @@ static int pm860x_rtc_alarm_irq_enable(struct device *dev, 
unsigned int enabled)
 static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
struct rtc_time *alrm)
 {
-   unsigned long next_time;
-   unsigned long now_time;
+   unsigned long long next_time;
+   unsigned long long now_time;
 
next->tm_year = now->tm_year;
next->tm_mon = now->tm_mon;
@@ -96,13 +96,13 @@ static void rtc_next_alarm_time(struct rtc_time *next, 
struct rtc_time *now,
next->tm_min = alrm->tm_min;
next->tm_sec = alrm->tm_sec;
 
-   rtc_tm_to_time(now, _time);
-   rtc_tm_to_time(next, _time);
+   now_time = rtc_tm_to_time64(now);
+   next_time = rtc_tm_to_time64(next);
 
if (next_time < now_time) {
/* Advance one day */
next_time += 60 * 60 * 24;
-   rtc_time_to_tm(next_time, next);
+   rtc_time64_to_tm(next_time, next);
}
 }
 
@@ -110,7 +110,7 @@ static int pm860x_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 {
struct pm860x_rtc_info *info = dev_get_drvdata(dev);
unsigned char buf[8];
-   unsigned long ticks, base, data;
+   unsigned long long ticks, base, data;
 
pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf);
dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1],
@@ -121,10 +121,10 @@ static int pm860x_rtc_read_time(struct device *dev, 
struct rtc_time *tm)
pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf);
data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
ticks = base + data;
-   dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+   dev_dbg(info->dev, "get base:0x%llx, RO count:0x%llx, ticks:0x%llx\n",
base, data, ticks);
 
-   rtc_time_to_tm(ticks, tm);
+   rtc_time64_to_tm(ticks, tm);
 
return 0;
 }
@@ -133,7 +133,7 @@ static int pm860x_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
 {
struct pm860x_rtc_info *info = dev_get_drvdata(dev);
unsigned char buf[4];
-   unsigned long ticks, base, data;
+   unsigned long long ticks, base, data;
 
if ((tm->tm_year < 70) || (tm->tm_year > 138)) {
dev_dbg(info->dev, "Set time %d out of range. "
@@ -141,13 +141,13 @@ static int pm860x_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
1900 + tm->tm_year);
return -EINVAL;
}
-   rtc_tm_to_time(tm, );
+   ticks = rtc_tm_to_time64(tm);
 
/* load 32-bit read-only counter */
pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf);
data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
base = ticks - data;
-   dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+   dev_dbg(info->dev, "set base:0x%llx, RO count:0x%llx, ticks:0x%llx\n",
base, data, ticks);
 
pm860x_page_reg_write(info->i2c, REG0_DATA, (base >> 24) & 0xFF);
@@ -164,7 +164,7 @@ static int pm860x_rtc_read_alarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 {
struct pm860x_rtc_info *info = dev_get_drvdata(dev);
unsigned char buf[8];
-   unsigned long ticks, base, data;
+   unsigned long long ticks, base, data;
int ret;
 
pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf);
@@ -175,10 +175,10 @@ static int pm860x_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
pm860x_bulk_read(info->i2c, PM8607_RTC_EXPIRE1, 4, buf);
data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
ticks = base + data;
-   dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+   dev_dbg(info->dev, "get base:0x%llx, RO count:0x%llx, ticks:0x%llx\n",
base, data, ticks);
 
-   rtc_time_to_tm(ticks, >time);
+   rtc_time64_to_tm(ticks, >time);
ret =

[rtc-linux] [PATCH 12/51] rtc: coh901331: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Linus Walleij <linus.wall...@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
CC: linux-arm-ker...@lists.infradead.org
---
 drivers/rtc/rtc-coh901331.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c
index cfc4141..5645011 100644
--- a/drivers/rtc/rtc-coh901331.c
+++ b/drivers/rtc/rtc-coh901331.c
@@ -80,7 +80,8 @@ static int coh901331_read_time(struct device *dev, struct 
rtc_time *tm)
clk_enable(rtap->clk);
/* Check if the time is valid */
if (readl(rtap->virtbase + COH901331_VALID)) {
-   rtc_time_to_tm(readl(rtap->virtbase + COH901331_CUR_TIME), tm);
+   rtc_time64_to_tm(
+   (u64)readl(rtap->virtbase + COH901331_CUR_TIME), tm);
clk_disable(rtap->clk);
return rtc_valid_tm(tm);
}
@@ -88,7 +89,7 @@ static int coh901331_read_time(struct device *dev, struct 
rtc_time *tm)
return -EINVAL;
 }
 
-static int coh901331_set_mmss(struct device *dev, unsigned long secs)
+static int coh901331_set_mmss64(struct device *dev, time64_t secs)
 {
struct coh901331_port *rtap = dev_get_drvdata(dev);
 
@@ -104,7 +105,8 @@ static int coh901331_read_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
struct coh901331_port *rtap = dev_get_drvdata(dev);
 
clk_enable(rtap->clk);
-   rtc_time_to_tm(readl(rtap->virtbase + COH901331_ALARM), >time);
+   rtc_time64_to_tm(
+   (u64)readl(rtap->virtbase + COH901331_ALARM), >time);
alarm->pending = readl(rtap->virtbase + COH901331_IRQ_EVENT) & 1U;
alarm->enabled = readl(rtap->virtbase + COH901331_IRQ_MASK) & 1U;
clk_disable(rtap->clk);
@@ -115,9 +117,9 @@ static int coh901331_read_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
 static int coh901331_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
struct coh901331_port *rtap = dev_get_drvdata(dev);
-   unsigned long time;
+   unsigned long long time;
 
-   rtc_tm_to_time(>time, );
+   time = rtc_tm_to_time64(>time);
clk_enable(rtap->clk);
writel(time, rtap->virtbase + COH901331_ALARM);
writel(alarm->enabled, rtap->virtbase + COH901331_IRQ_MASK);
@@ -142,7 +144,7 @@ static int coh901331_alarm_irq_enable(struct device *dev, 
unsigned int enabled)
 
 static const struct rtc_class_ops coh901331_ops = {
.read_time = coh901331_read_time,
-   .set_mmss = coh901331_set_mmss,
+   .set_mmss64 = coh901331_set_mmss64,
.read_alarm = coh901331_read_alarm,
.set_alarm = coh901331_set_alarm,
.alarm_irq_enable = coh901331_alarm_irq_enable,
-- 
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.


[rtc-linux] [PATCH 19/51] rtc: ds1305: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-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(>time, );
-   if (status < 0)
-   return status;
+   later = rtc_tm_to_time64(>time);
 
/* Read current time as time_t */
status = ds1305_get_time(dev, );
if (status < 0)
return status;
-   status = rtc_tm_to_time(, );
-   if (status < 0)
-   return status;
+
+   now = rtc_tm_to_time64();
 
/* make sure alarm fires within the next 24 hours */
if (later <= now)
-- 
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.


[rtc-linux] [PATCH 08/51] rtc: armada38x: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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: Jason Cooper <ja...@lakedaemon.net>
CC: Gregory Clement <gregory.clem...@free-electrons.com>
CC: Sebastian Hesselbarth <sebastian.hesselba...@gmail.com>
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-armada38x.c | 34 ++
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
index 21f355c..752ebf4 100644
--- a/drivers/rtc/rtc-armada38x.c
+++ b/drivers/rtc/rtc-armada38x.c
@@ -213,13 +213,14 @@ static void armada8k_unmask_interrupt(struct 
armada38x_rtc *rtc)
 static int armada38x_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
struct armada38x_rtc *rtc = dev_get_drvdata(dev);
-   unsigned long time, flags;
+   unsigned long long time;
+   unsigned long flags;
 
spin_lock_irqsave(>lock, flags);
time = rtc->data->read_rtc_reg(rtc, RTC_TIME);
spin_unlock_irqrestore(>lock, flags);
 
-   rtc_time_to_tm(time, tm);
+   rtc_time64_to_tm(time, tm);
 
return 0;
 }
@@ -227,26 +228,23 @@ static int armada38x_rtc_read_time(struct device *dev, 
struct rtc_time *tm)
 static int armada38x_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
struct armada38x_rtc *rtc = dev_get_drvdata(dev);
-   int ret = 0;
-   unsigned long time, flags;
-
-   ret = rtc_tm_to_time(tm, );
+   unsigned long long time;
+   unsigned long flags;
 
-   if (ret)
-   goto out;
+   time = rtc_tm_to_time64(tm);
 
spin_lock_irqsave(>lock, flags);
rtc_delayed_write(time, rtc, RTC_TIME);
spin_unlock_irqrestore(>lock, flags);
 
-out:
-   return ret;
+   return 0;
 }
 
 static int armada38x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm 
*alrm)
 {
struct armada38x_rtc *rtc = dev_get_drvdata(dev);
-   unsigned long time, flags;
+   unsigned long long time;
+   unsigned long flags;
u32 reg = ALARM_REG(RTC_ALARM1, rtc->data->alarm);
u32 reg_irq = ALARM_REG(RTC_IRQ1_CONF, rtc->data->alarm);
u32 val;
@@ -259,7 +257,7 @@ static int armada38x_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
spin_unlock_irqrestore(>lock, flags);
 
alrm->enabled = val ? 1 : 0;
-   rtc_time_to_tm(time,  >time);
+   rtc_time64_to_tm(time,  >time);
 
return 0;
 }
@@ -269,13 +267,10 @@ static int armada38x_rtc_set_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
struct armada38x_rtc *rtc = dev_get_drvdata(dev);
u32 reg = ALARM_REG(RTC_ALARM1, rtc->data->alarm);
u32 reg_irq = ALARM_REG(RTC_IRQ1_CONF, rtc->data->alarm);
-   unsigned long time, flags;
-   int ret = 0;
-
-   ret = rtc_tm_to_time(>time, );
+   unsigned long long time;
+   unsigned long flags;
 
-   if (ret)
-   goto out;
+   time = rtc_tm_to_time64(>time);
 
spin_lock_irqsave(>lock, flags);
 
@@ -288,8 +283,7 @@ static int armada38x_rtc_set_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
 
spin_unlock_irqrestore(>lock, flags);
 
-out:
-   return ret;
+   return 0;
 }
 
 static int armada38x_rtc_alarm_irq_enable(struct device *dev,
-- 
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.


[rtc-linux] [PATCH 04/51] rtc: 88pm80x: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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-88pm80x.c | 44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c
index 466bf7f..1898e9b 100644
--- a/drivers/rtc/rtc-88pm80x.c
+++ b/drivers/rtc/rtc-88pm80x.c
@@ -90,8 +90,8 @@ static int pm80x_rtc_alarm_irq_enable(struct device *dev, 
unsigned int enabled)
 static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
struct rtc_time *alrm)
 {
-   unsigned long next_time;
-   unsigned long now_time;
+   unsigned long long next_time;
+   unsigned long long now_time;
 
next->tm_year = now->tm_year;
next->tm_mon = now->tm_mon;
@@ -100,13 +100,13 @@ static void rtc_next_alarm_time(struct rtc_time *next, 
struct rtc_time *now,
next->tm_min = alrm->tm_min;
next->tm_sec = alrm->tm_sec;
 
-   rtc_tm_to_time(now, _time);
-   rtc_tm_to_time(next, _time);
+   now_time = rtc_tm_to_time64(now);
+   next_time = rtc_tm_to_time64(next);
 
if (next_time < now_time) {
/* Advance one day */
next_time += 60 * 60 * 24;
-   rtc_time_to_tm(next_time, next);
+   rtc_time64_to_tm(next_time, next);
}
 }
 
@@ -114,7 +114,7 @@ static int pm80x_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 {
struct pm80x_rtc_info *info = dev_get_drvdata(dev);
unsigned char buf[4];
-   unsigned long ticks, base, data;
+   unsigned long long ticks, base, data;
regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4);
base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]);
@@ -123,9 +123,9 @@ static int pm80x_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4);
data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
ticks = base + data;
-   dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+   dev_dbg(info->dev, "get base:0x%llx, RO count:0x%llx, ticks:0x%llx\n",
base, data, ticks);
-   rtc_time_to_tm(ticks, tm);
+   rtc_time64_to_tm(ticks, tm);
return 0;
 }
 
@@ -133,20 +133,20 @@ static int pm80x_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
 {
struct pm80x_rtc_info *info = dev_get_drvdata(dev);
unsigned char buf[4];
-   unsigned long ticks, base, data;
+   unsigned long long ticks, base, data;
if ((tm->tm_year < 70) || (tm->tm_year > 138)) {
dev_dbg(info->dev,
"Set time %d out of range. Please set time between 1970 
to 2038.\n",
1900 + tm->tm_year);
return -EINVAL;
}
-   rtc_tm_to_time(tm, );
+   ticks = rtc_tm_to_time64(tm);
 
/* load 32-bit read-only counter */
regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4);
data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
base = ticks - data;
-   dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+   dev_dbg(info->dev, "set base:0x%llx, RO count:0x%llx, ticks:0x%llx\n",
base, data, ticks);
buf[0] = base & 0xFF;
buf[1] = (base >> 8) & 0xFF;
@@ -161,7 +161,7 @@ static int pm80x_rtc_read_alarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 {
struct pm80x_rtc_info *info = dev_get_drvdata(dev);
unsigned char buf[4];
-   unsigned long ticks, base, data;
+   unsigned long long ticks, base, data;
int ret;
 
regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4);
@@ -171,10 +171,10 @@ static int pm80x_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
regmap_raw_read(info->map, PM800_RTC_EXPIRE1_1, buf, 4);
data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
ticks = base + data;
-   dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
+   dev_dbg(info->dev, "get base:0x%llx, RO count:0x%llx, ticks:0x%llx\n",
base, data, ticks);
 
-   rtc_time_to_tm(ticks, >time);
+   rtc_tim

[rtc-linux] [PATCH 00/51] rtc: stop using rtc deprecated functions

2017-06-20 Thread Benjamin Gaignard
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.

The goal of this series of patches is ti stop using those two functions
and use instead to safer 64bits ones.

It also remove change .set_mmss to set_mmss64 callback for the same reasons.

Those 51 patches almost clean all the drivers except the few that I haven't
been able to compile because of cross-toolchains issues (au1xxx, mpc5121, ps3,
puv3, sun4v, tx4939, starfire, ls1x ...)

Obviously I don't have all those hardwares in my hands so I have only check
that the patches compile without warnings but it up to each maintainer to
valid them on real hardware.

Benjamin Gaignard (51):
  x86: rtc: stop using rtc deprecated functions
  x86: intel-mid: vrtc: stop using rtc deprecated functions
  net: broadcom: stop using rtc deprecated functions
  rtc: 88pm80x: stop using rtc deprecated functions
  rtc: 88pm860x: stop using rtc deprecated functions
  rtc: ab-b5ze-s3: stop using rtc deprecated functions
  rtc: ab8500: stop using rtc deprecated functions
  rtc: armada38x: stop using rtc deprecated functions
  rtc: at32ap700x: stop using rtc deprecated functions
  rtc: at91sam9: stop using rtc deprecated functions
  rtc: bfin: stop using rtc deprecated functions
  rtc: coh901331: stop using rtc deprecated functions
  rtc: cpcap: stop using rtc deprecated functions
  rtc: da9063: stop using rtc deprecated functions
  rtc: da9063: stop using rtc deprecated functions
  rtc: davinci: stop using rtc deprecated functions
  rtc: digicolor: stop using rtc deprecated functions
  rtc: dm355evm: stop using rtc deprecated functions
  rtc: ds1305: stop using rtc deprecated functions
  rtc: ds1374: stop using rtc deprecated functions
  rtc: ds1511: stop using rtc deprecated functions
  rtc: ds1553: stop using rtc deprecated functions
  rtc: ds1672: stop using rtc deprecated functions
  rtc: ds2404: stop using rtc deprecated functions
  rtc: ep93xx: stop using rtc deprecated functions
  rtc: gemini: stop using rtc deprecated functions
  rtc: imxdi: stop using rtc deprecated functions
  rtc: jz4740: stop using rtc deprecated functions
  rtc: lpc32xx: 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: pl030: stop using rtc deprecated functions
  rtc: pl031: stop using rtc deprecated functions
  rtc: pm8xxx: stop using rtc deprecated functions
  rtc: rs5c348: stop using rtc deprecated functions
  rtc: sa1100: stop using rtc deprecated functions
  rtc: sh: stop using rtc deprecated functions
  rtc: sirfsoc: stop using rtc deprecated functions
  rtc: snvs: stop using rtc deprecated functions
  rtc: stk17ta8: stop using rtc deprecated functions
  rtc: stmp3xxx: stop using rtc deprecated functions
  rtc: sun6i: stop using rtc deprecated functions
  rtc: sysfs: stop using rtc deprecated functions
  rtc: tegra stop using rtc deprecated functions
  rtc: test: stop using rtc deprecated functions
  rtc: tps6586: stop using rtc deprecated functions
  rtc: vr41xx: stop using rtc deprecated functions
  rtc: wm831x: stop using rtc deprecated functions
  rtc: xgene 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-88pm80x.c| 44 +--
 drivers/rtc/rtc-88pm860x.c   | 40 -
 drivers/rtc/rtc-ab-b5ze-s3.c | 45 
 drivers/rtc/rtc-ab8500.c | 26 
 drivers/rtc/rtc-armada38x.c  | 34 +
 drivers/rtc/rtc-at32ap700x.c | 29 --
 drivers/rtc/rtc-at91sam9.c   | 18 ---
 drivers/rtc/rtc-bfin.c   | 24 +++
 drivers/rtc/rtc-coh901331.c  | 14 +
 drivers/rtc/rtc-cpcap.c  |  8 ++---
 drivers/rtc/rtc-da9052.c |  8 ++---
 drivers/rtc/rtc-da9063.c |  8 ++---
 drivers/rtc/rtc-davinci.c|  8 ++---
 drivers/rtc/rtc-digicolor.c  |  4 +--
 drivers/rtc/rtc-dm355evm.c   |  6 ++--
 drivers/rtc/rtc-ds1305.c | 11 +++
 drivers/rtc/rtc-ds1374.c |  6 ++--
 drivers/rtc/rtc-ds1511.c |  2 +-
 drivers/rtc/rtc-ds1553.c |  2 +-
 drivers/rtc/rtc-ds1672.c |  8 ++---
 drivers/rtc/rtc-ds2404.c |  8 ++---
 drivers/rtc/rtc-ep93xx.c | 10 +++
 drivers/rtc/rtc-gemini.c |  8 ++---
 drivers/rtc/rtc-imxdi.c  | 16

[rtc-linux] [PATCH v2 0/3] rtc: make st-lpc robust against y2038/2106 bug

2017-06-19 Thread Benjamin Gaignard
On 32bits platforms "struct timeval" or "time_t" are using u32 to code the
date, this cause tools like "date" or "hwclock" failed even before setting
the RTC device if the date is superior to year 2038 (or 2106).

To avoid this problem I add one RTC test file which directly use RTC ioctl
to set and read RTC time and alarm values.
rtctest_setdate allow to set any date/time given in the command line.

On this version 2 I add check of problematics years in rtctest like suggest
by Alexandre.

Finally that had allowed me to test and fix rtc-st-lpc driver.

Benjamin Gaignard (3):
  tools: timer: add rtctest_setdate
  tool: timer: rtctest add check for problematic dates
  rtc: st-lpc: make it robust against y2038/2106 bug

 drivers/rtc/rtc-st-lpc.c |  19 ++--
 tools/testing/selftests/timers/Makefile  |   2 +-
 tools/testing/selftests/timers/rtctest.c | 121 ++-
 tools/testing/selftests/timers/rtctest_setdate.c |  86 
 4 files changed, 212 insertions(+), 16 deletions(-)
 create mode 100644 tools/testing/selftests/timers/rtctest_setdate.c

-- 
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.


[rtc-linux] [PATCH v2 3/3] rtc: st-lpc: make it robust against y2038/2106 bug

2017-06-19 Thread Benjamin Gaignard
Make driver use u64 variables and functions to be sure that
it will support dates after year 2038.

Signed-off-by: Benjamin Gaignard <benjamin.gaign...@linaro.org>
Acked-by: Patrice Chotard <patrice.chot...@st.com>
---
 drivers/rtc/rtc-st-lpc.c | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-st-lpc.c b/drivers/rtc/rtc-st-lpc.c
index 74c0a33..82b0af1 100644
--- a/drivers/rtc/rtc-st-lpc.c
+++ b/drivers/rtc/rtc-st-lpc.c
@@ -99,7 +99,7 @@ static int st_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 
lpt = ((unsigned long long)lpt_msb << 32) | lpt_lsb;
do_div(lpt, rtc->clkrate);
-   rtc_time_to_tm(lpt, tm);
+   rtc_time64_to_tm(lpt, tm);
 
return 0;
 }
@@ -107,13 +107,10 @@ static int st_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
 static int st_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
struct st_rtc *rtc = dev_get_drvdata(dev);
-   unsigned long long lpt;
-   unsigned long secs, flags;
-   int ret;
+   unsigned long long lpt, secs;
+   unsigned long flags;
 
-   ret = rtc_tm_to_time(tm, );
-   if (ret)
-   return ret;
+   secs = rtc_tm_to_time64(tm);
 
lpt = (unsigned long long)secs * rtc->clkrate;
 
@@ -161,13 +158,13 @@ static int st_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *t)
 {
struct st_rtc *rtc = dev_get_drvdata(dev);
struct rtc_time now;
-   unsigned long now_secs;
-   unsigned long alarm_secs;
+   unsigned long long now_secs;
+   unsigned long long alarm_secs;
unsigned long long lpa;
 
st_rtc_read_time(dev, );
-   rtc_tm_to_time(, _secs);
-   rtc_tm_to_time(>time, _secs);
+   now_secs = rtc_tm_to_time64();
+   alarm_secs = rtc_tm_to_time64(>time);
 
/* Invalid alarm time */
if (now_secs > alarm_secs)
-- 
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.


[rtc-linux] [PATCH v2 1/3] tools: timer: add rtctest_setdate

2017-06-19 Thread Benjamin Gaignard
This tool allow to set directly the time and date to a RTC device.

Unlike other tools isn't doens't use "struct timeval" or "time_t"
so it is safe for 32bits platforms when testing for y2038/2106 bug.

Signed-off-by: Benjamin Gaignard <benjamin.gaign...@linaro.org>
---
 tools/testing/selftests/timers/Makefile  |  2 +-
 tools/testing/selftests/timers/rtctest_setdate.c | 86 
 2 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/rtctest_setdate.c

diff --git a/tools/testing/selftests/timers/Makefile 
b/tools/testing/selftests/timers/Makefile
index 5fa1d7e9..54481f1 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -9,7 +9,7 @@ TEST_GEN_PROGS = posix_timers nanosleep nsleep-lat 
set-timer-lat mqueue-lat \
 
 TEST_GEN_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick 
change_skew \
  skew_consistency clocksource-switch leap-a-day \
- leapcrash set-tai set-2038 set-tz
+ leapcrash set-tai set-2038 set-tz rtctest_setdate
 
 
 include ../lib.mk
diff --git a/tools/testing/selftests/timers/rtctest_setdate.c 
b/tools/testing/selftests/timers/rtctest_setdate.c
new file mode 100644
index 000..2cb7848
--- /dev/null
+++ b/tools/testing/selftests/timers/rtctest_setdate.c
@@ -0,0 +1,86 @@
+/* Real Time Clock Driver Test
+ * by: Benjamin Gaignard (benjamin.gaign...@linaro.org)
+ *
+ * To build
+ * gcc rtctest_setdate.c -o rtctest_setdate
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const char default_time[] = "00:00:00";
+
+int main(int argc, char **argv)
+{
+   int fd, retval;
+   struct rtc_time new, current;
+   const char *rtc, *date;
+   const char *time = default_time;
+
+   switch (argc) {
+   case 4:
+   time = argv[3];
+   /* FALLTHROUGH */
+   case 3:
+   date = argv[2];
+   rtc = argv[1];
+   break;
+   default:
+   fprintf(stderr, "usage: rtctest_setdate   
[HH:MM:SS]\n");
+   return 1;
+   }
+
+   fd = open(rtc, O_RDONLY);
+   if (fd == -1) {
+   perror(rtc);
+   exit(errno);
+   }
+
+   sscanf(date, "%d-%d-%d", _mday, _mon, _year);
+   new.tm_mon -= 1;
+   new.tm_year -= 1900;
+   sscanf(time, "%d:%d:%d", _hour, _min, _sec);
+
+   fprintf(stderr, "Test will set RTC date/time to %d-%d-%d, 
%02d:%02d:%02d.\n",
+   new.tm_mday, new.tm_mon + 1, new.tm_year + 1900,
+   new.tm_hour, new.tm_min, new.tm_sec);
+
+   /* Write the new date in RTC */
+   retval = ioctl(fd, RTC_SET_TIME, );
+   if (retval == -1) {
+   perror("RTC_SET_TIME ioctl");
+   close(fd);
+   exit(errno);
+   }
+
+   /* Read back */
+   retval = ioctl(fd, RTC_RD_TIME, );
+   if (retval == -1) {
+   perror("RTC_RD_TIME ioctl");
+   exit(errno);
+   }
+
+   fprintf(stderr, "\n\nCurrent RTC date/time is %d-%d-%d, 
%02d:%02d:%02d.\n",
+   current.tm_mday, current.tm_mon + 1, current.tm_year + 1900,
+   current.tm_hour, current.tm_min, current.tm_sec);
+
+   close(fd);
+   return 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.


[rtc-linux] [PATCH 1/3] tools: timer: add rtctest_setdate

2017-06-16 Thread Benjamin Gaignard
This tool allow to set directly the time and date to a RTC device.

Unlike other tools isn't doens't use "strut timeval" or "time_t"
so it is safe for 32bits platforms when testing for y2038/2106 bug.

Signed-off-by: Benjamin Gaignard <benjamin.gaign...@linaro.org>
---
 tools/testing/selftests/timers/Makefile  |  2 +-
 tools/testing/selftests/timers/rtctest_setdate.c | 86 
 2 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/rtctest_setdate.c

diff --git a/tools/testing/selftests/timers/Makefile 
b/tools/testing/selftests/timers/Makefile
index 5fa1d7e9..54481f1 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -9,7 +9,7 @@ TEST_GEN_PROGS = posix_timers nanosleep nsleep-lat 
set-timer-lat mqueue-lat \
 
 TEST_GEN_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick 
change_skew \
  skew_consistency clocksource-switch leap-a-day \
- leapcrash set-tai set-2038 set-tz
+ leapcrash set-tai set-2038 set-tz rtctest_setdate
 
 
 include ../lib.mk
diff --git a/tools/testing/selftests/timers/rtctest_setdate.c 
b/tools/testing/selftests/timers/rtctest_setdate.c
new file mode 100644
index 000..2cb7848
--- /dev/null
+++ b/tools/testing/selftests/timers/rtctest_setdate.c
@@ -0,0 +1,86 @@
+/* Real Time Clock Driver Test
+ * by: Benjamin Gaignard (benjamin.gaign...@linaro.org)
+ *
+ * To build
+ * gcc rtctest_setdate.c -o rtctest_setdate
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const char default_time[] = "00:00:00";
+
+int main(int argc, char **argv)
+{
+   int fd, retval;
+   struct rtc_time new, current;
+   const char *rtc, *date;
+   const char *time = default_time;
+
+   switch (argc) {
+   case 4:
+   time = argv[3];
+   /* FALLTHROUGH */
+   case 3:
+   date = argv[2];
+   rtc = argv[1];
+   break;
+   default:
+   fprintf(stderr, "usage: rtctest_setdate   
[HH:MM:SS]\n");
+   return 1;
+   }
+
+   fd = open(rtc, O_RDONLY);
+   if (fd == -1) {
+   perror(rtc);
+   exit(errno);
+   }
+
+   sscanf(date, "%d-%d-%d", _mday, _mon, _year);
+   new.tm_mon -= 1;
+   new.tm_year -= 1900;
+   sscanf(time, "%d:%d:%d", _hour, _min, _sec);
+
+   fprintf(stderr, "Test will set RTC date/time to %d-%d-%d, 
%02d:%02d:%02d.\n",
+   new.tm_mday, new.tm_mon + 1, new.tm_year + 1900,
+   new.tm_hour, new.tm_min, new.tm_sec);
+
+   /* Write the new date in RTC */
+   retval = ioctl(fd, RTC_SET_TIME, );
+   if (retval == -1) {
+   perror("RTC_SET_TIME ioctl");
+   close(fd);
+   exit(errno);
+   }
+
+   /* Read back */
+   retval = ioctl(fd, RTC_RD_TIME, );
+   if (retval == -1) {
+   perror("RTC_RD_TIME ioctl");
+   exit(errno);
+   }
+
+   fprintf(stderr, "\n\nCurrent RTC date/time is %d-%d-%d, 
%02d:%02d:%02d.\n",
+   current.tm_mday, current.tm_mon + 1, current.tm_year + 1900,
+   current.tm_hour, current.tm_min, current.tm_sec);
+
+   close(fd);
+   return 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.


[rtc-linux] [PATCH 2/3] tools: timer: add test to check y2038/2106 bug

2017-06-16 Thread Benjamin Gaignard
The goal of this test is to check if a RTC device correctly support
dates after years 2038 or 2106.
It set a date (1-1-2200) on RTC and read it back to be sure that the
driver is working well.
The same thing is done on alarm.

Signed-off-by: Benjamin Gaignard <benjamin.gaign...@linaro.org>
---
 tools/testing/selftests/timers/Makefile   |   4 +-
 tools/testing/selftests/timers/rtctest-2038.c | 135 ++
 2 files changed, 138 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/rtctest-2038.c

diff --git a/tools/testing/selftests/timers/Makefile 
b/tools/testing/selftests/timers/Makefile
index 54481f1..7791f79 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -9,7 +9,8 @@ TEST_GEN_PROGS = posix_timers nanosleep nsleep-lat 
set-timer-lat mqueue-lat \
 
 TEST_GEN_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick 
change_skew \
  skew_consistency clocksource-switch leap-a-day \
- leapcrash set-tai set-2038 set-tz rtctest_setdate
+ leapcrash set-tai set-2038 set-tz rtctest_setdate \
+ rtctest-2038
 
 
 include ../lib.mk
@@ -29,4 +30,5 @@ run_destructive_tests: run_tests
./set-tz
./set-tai
./set-2038
+   ./rtctest-2038
 
diff --git a/tools/testing/selftests/timers/rtctest-2038.c 
b/tools/testing/selftests/timers/rtctest-2038.c
new file mode 100644
index 000..213b7ee
--- /dev/null
+++ b/tools/testing/selftests/timers/rtctest-2038.c
@@ -0,0 +1,135 @@
+/* Real Time Clock Driver Test
+ *     by: Benjamin Gaignard (benjamin.gaign...@linaro.org)
+ *
+ * To build
+ * gcc rtctest-2038.c -o rtctest-2038
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const char default_rtc[] = "/dev/rtc0";
+
+int main(int argc, char **argv)
+{
+   int fd, retval;
+   struct rtc_time new, current;
+   const char *rtc = default_rtc;
+
+   switch (argc) {
+   case 2:
+   rtc = argv[1];
+   /* FALLTHROUGH */
+   case 1:
+   break;
+   default:
+   fprintf(stderr, "usage: rtctest-2038 [rtcdev]\n");
+   return 1;
+   }
+
+   fprintf(stderr, "\nTest if RTC is robust for date after 
y2038/2106\n\n");
+
+   fd = open(rtc, O_RDONLY);
+   if (fd == -1) {
+   perror(rtc);
+   exit(errno);
+   }
+
+   new.tm_year = 300; /* 2200 - 1900 */
+   new.tm_mon = 0;
+   new.tm_mday = 1;
+   new.tm_hour = 0;
+   new.tm_min = 0;
+   new.tm_sec = 0;
+
+   fprintf(stderr, "Test will set RTC date/time to %d-%d-%d, 
%02d:%02d:%02d.\n",
+   new.tm_mday, new.tm_mon + 1, new.tm_year + 1900,
+   new.tm_hour, new.tm_min, new.tm_sec);
+
+   /* Write the new date in RTC */
+   retval = ioctl(fd, RTC_SET_TIME, );
+   if (retval == -1) {
+   perror("RTC_SET_TIME ioctl");
+   close(fd);
+   exit(errno);
+   }
+
+   /* Read back */
+   retval = ioctl(fd, RTC_RD_TIME, );
+   if (retval == -1) {
+   perror("RTC_RD_TIME ioctl");
+   exit(errno);
+   }
+
+   fprintf(stderr, "RTC date/time is %d-%d-%d, %02d:%02d:%02d.\n",
+   current.tm_mday, current.tm_mon + 1, current.tm_year + 1900,
+   current.tm_hour, current.tm_min, current.tm_sec);
+
+   if (new.tm_year != current.tm_year ||
+   new.tm_mon != current.tm_mon ||
+   new.tm_mday != current.tm_mday ||
+   new.tm_hour != current.tm_hour ||
+   new.tm_min != current.tm_min ||
+   new.tm_sec != current.tm_sec) {
+   fprintf(stderr, "\n\nSet Time test failed\n");
+   close(fd);
+   return 1;
+   }
+
+   new.tm_sec += 5;
+
+   fprintf(stderr, "\nTest will set RTC alarm to %d-%d-%d, 
%02d:%02d:%02d.\n",
+   new.tm_mday, new.tm_mon + 1, new.tm_year + 1900,
+   new.tm_hour, new.tm_min, new.tm_sec);
+
+   /* Write the new alarm in RTC */
+   retval = ioctl(fd, RTC_ALM_SET, );
+   if (retval == -1) {
+   perror("RTC_ALM_SET ioctl");
+   close(fd);
+   exit(errno)