2017-06-20 09:37:05

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 00/51] rtc: stop using rtc deprecated functions

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 +++++-----
drivers/rtc/rtc-jz4740.c | 12 ++++----
drivers/rtc/rtc-lpc32xx.c | 19 +++++-------
drivers/rtc/rtc-mv.c | 2 +-
drivers/rtc/rtc-omap.c | 6 ++--
drivers/rtc/rtc-pcap.c | 16 +++++-----
drivers/rtc/rtc-pl030.c | 24 +++++++--------
drivers/rtc/rtc-pl031.c | 31 ++++++++-----------
drivers/rtc/rtc-pm8xxx.c | 22 +++++++-------
drivers/rtc/rtc-rs5c348.c | 4 +--
drivers/rtc/rtc-sa1100.c | 25 +++++++---------
drivers/rtc/rtc-sh.c | 2 +-
drivers/rtc/rtc-sirfsoc.c | 18 +++++------
drivers/rtc/rtc-snvs.c | 14 ++++-----
drivers/rtc/rtc-stk17ta8.c | 2 +-
drivers/rtc/rtc-stmp3xxx.c | 12 ++++----
drivers/rtc/rtc-sun6i.c | 14 ++++-----
drivers/rtc/rtc-sysfs.c | 25 ++++++++--------
drivers/rtc/rtc-tegra.c | 22 +++++++-------
drivers/rtc/rtc-test.c | 17 +----------
drivers/rtc/rtc-tps6586x.c | 26 ++++++++--------
drivers/rtc/rtc-vr41xx.c | 6 ++--
drivers/rtc/rtc-wm831x.c | 28 +++++++----------
drivers/rtc/rtc-xgene.c | 12 ++++----
kernel/power/suspend_test.c | 6 ++--
51 files changed, 342 insertions(+), 420 deletions(-)

--
CC: [email protected]
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: Gregory Clement <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Jason Cooper <[email protected]>
CC: John Stultz <[email protected]>
CC: [email protected]
CC: [email protected]
CC: Linus Walleij <[email protected]>
CC: Michael Chan <[email protected]>
CC: [email protected]
CC: [email protected]
CC: Sebastian Hesselbarth <[email protected]>
CC: Support Opensource <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: [email protected]
CC: Baruch Siach <[email protected]>
CC: Hans Ulli Kroll <[email protected]>
CC: Vladimir Zapolskiy <[email protected]>
CC: Sylvain Lemieux <[email protected]>
CC: Barry Song <[email protected]>
CC: Maxime Ripard <[email protected]>
CC: Chen-Yu Tsai <[email protected]>
CC: Thierry Reding <[email protected]>
CC: Jonathan Hunter <[email protected]>
CC: [email protected]
CC: [email protected]
CC: "Rafael J. Wysocki" <[email protected]>
CC: Pavel Machek <[email protected]>
CC: Len Brown <[email protected]>
CC: [email protected]

1.9.1


2017-06-20 09:37:10

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 04/51] rtc: 88pm80x: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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, &now_time);
- rtc_tm_to_time(next, &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);
+ 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, &alrm->time);
+ rtc_time64_to_tm(ticks, &alrm->time);
regmap_read(info->map, PM800_RTC_CONTROL, &ret);
alrm->enabled = (ret & PM800_ALARM1_EN) ? 1 : 0;
alrm->pending = (ret & (PM800_ALARM | PM800_ALARM_WAKEUP)) ? 1 : 0;
@@ -185,7 +185,7 @@ static int pm80x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct pm80x_rtc_info *info = dev_get_drvdata(dev);
struct rtc_time now_tm, alarm_tm;
- unsigned long ticks, base, data;
+ unsigned long long ticks, base, data;
unsigned char buf[4];
int mask;

@@ -199,15 +199,15 @@ static int pm80x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
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, &now_tm);
- dev_dbg(info->dev, "%s, now time : %lu\n", __func__, ticks);
+ rtc_time64_to_tm(ticks, &now_tm);
+ dev_dbg(info->dev, "%s, now time : %llu\n", __func__, ticks);
rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
/* get new ticks for alarm in 24 hours */
- rtc_tm_to_time(&alarm_tm, &ticks);
- dev_dbg(info->dev, "%s, alarm time: %lu\n", __func__, ticks);
+ ticks = rtc_tm_to_time64(&alarm_tm);
+ dev_dbg(info->dev, "%s, alarm time: %llu\n", __func__, ticks);
data = ticks - base;

buf[0] = data & 0xff;
@@ -255,7 +255,7 @@ static int pm80x_rtc_probe(struct platform_device *pdev)
struct pm80x_rtc_info *info;
struct device_node *node = pdev->dev.of_node;
struct rtc_time tm;
- unsigned long ticks = 0;
+ unsigned long long ticks = 0;
int ret;

if (!pdata && !node) {
@@ -320,7 +320,7 @@ static int pm80x_rtc_probe(struct platform_device *pdev)
goto out_rtc;
}
}
- rtc_tm_to_time(&tm, &ticks);
+ ticks = rtc_tm_to_time64(&tm);

info->rtc_dev = devm_rtc_device_register(&pdev->dev, "88pm80x-rtc",
&pm80x_rtc_ops, THIS_MODULE);
--
1.9.1

2017-06-20 09:37:21

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 11/51] rtc: bfin: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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, &now);
- 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(&alrm->time, &rtc_alarm))
- return -EINVAL;
+ rtc_alarm = rtc_tm_to_time64(&alrm->time);

rtc->rtc_alarm = alrm->time;

--
1.9.1

2017-06-20 09:37:28

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 13/51] rtc: cpcap: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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);
+ time = rtc_tm_to_time64(rtc);

cpcap->day = time / SECS_PER_DAY;
time %= SECS_PER_DAY;
--
1.9.1

2017-06-20 09:37:36

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 17/51] rtc: digicolor: stop using rtc deprecated functions

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 <[email protected]>
CC: Baruch Siach <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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

2017-06-20 09:38:01

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 22/51] rtc: ds1553: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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

2017-06-20 09:38:05

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 25/51] rtc: ep93xx: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-ep93xx.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index 6940382..dcb71b2 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -59,15 +59,15 @@ static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload,
static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev);
- unsigned long time;
+ unsigned long long time;

- time = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA);
+ time = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA);

- rtc_time_to_tm(time, tm);
+ rtc_time64_to_tm(time, tm);
return 0;
}

-static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int ep93xx_rtc_set_mmss64(struct device *dev, time64_t secs)
{
struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev);

@@ -89,7 +89,7 @@ static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)

static const struct rtc_class_ops ep93xx_rtc_ops = {
.read_time = ep93xx_rtc_read_time,
- .set_mmss = ep93xx_rtc_set_mmss,
+ .set_mmss64 = ep93xx_rtc_set_mmss64,
.proc = ep93xx_rtc_proc,
};

--
1.9.1

2017-06-20 09:38:10

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 24/51] rtc: ds2404: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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);
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 *)&time);
@@ -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

2017-06-20 09:38:46

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 44/51] rtc: sysfs: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-sysfs.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index e364550..8b97def 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -72,9 +72,10 @@

retval = rtc_read_time(to_rtc_device(dev), &tm);
if (retval == 0) {
- unsigned long time;
- rtc_tm_to_time(&tm, &time);
- retval = sprintf(buf, "%lu\n", time);
+ unsigned long long time;
+
+ time = rtc_tm_to_time64(&tm);
+ retval = sprintf(buf, "%llu\n", time);
}

return retval;
@@ -132,7 +133,7 @@
wakealarm_show(struct device *dev, struct device_attribute *attr, char *buf)
{
ssize_t retval;
- unsigned long alarm;
+ unsigned long long alarm;
struct rtc_wkalrm alm;

/* Don't show disabled alarms. For uniformity, RTC alarms are
@@ -145,8 +146,8 @@
*/
retval = rtc_read_alarm(to_rtc_device(dev), &alm);
if (retval == 0 && alm.enabled) {
- rtc_tm_to_time(&alm.time, &alarm);
- retval = sprintf(buf, "%lu\n", alarm);
+ alarm = rtc_tm_to_time64(&alm.time);
+ retval = sprintf(buf, "%llu\n", alarm);
}

return retval;
@@ -157,8 +158,8 @@
const char *buf, size_t n)
{
ssize_t retval;
- unsigned long now, alarm;
- unsigned long push = 0;
+ unsigned long long now, alarm;
+ unsigned long long push = 0;
struct rtc_wkalrm alm;
struct rtc_device *rtc = to_rtc_device(dev);
const char *buf_ptr;
@@ -170,7 +171,7 @@
retval = rtc_read_time(rtc, &alm.time);
if (retval < 0)
return retval;
- rtc_tm_to_time(&alm.time, &now);
+ now = rtc_tm_to_time64(&alm.time);

buf_ptr = buf;
if (*buf_ptr == '+') {
@@ -181,7 +182,7 @@
} else
adjust = 1;
}
- retval = kstrtoul(buf_ptr, 0, &alarm);
+ retval = kstrtoull(buf_ptr, 0, &alarm);
if (retval)
return retval;
if (adjust) {
@@ -197,7 +198,7 @@
return retval;
if (alm.enabled) {
if (push) {
- rtc_tm_to_time(&alm.time, &push);
+ push = rtc_tm_to_time64(&alm.time);
alarm += push;
} else
return -EBUSY;
@@ -212,7 +213,7 @@
*/
alarm = now + 300;
}
- rtc_time_to_tm(alarm, &alm.time);
+ rtc_time64_to_tm(alarm, &alm.time);

retval = rtc_set_alarm(rtc, &alm);
return (retval < 0) ? retval : n;
--
1.9.1

2017-06-20 09:38:57

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 51/51] power: suspend test: stop using rtc deprecated functions

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 <[email protected]>
CC: "Rafael J. Wysocki" <[email protected]>
CC: Pavel Machek <[email protected]>
CC: Len Brown <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
kernel/power/suspend_test.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/power/suspend_test.c b/kernel/power/suspend_test.c
index 5db2170..334a893 100644
--- a/kernel/power/suspend_test.c
+++ b/kernel/power/suspend_test.c
@@ -71,7 +71,7 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
static char info_test[] __initdata =
KERN_INFO "PM: test RTC wakeup from '%s' suspend\n";

- unsigned long now;
+ unsigned long long now;
struct rtc_wkalrm alm;
int status;

@@ -82,10 +82,10 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
printk(err_readtime, dev_name(&rtc->dev), status);
return;
}
- rtc_tm_to_time(&alm.time, &now);
+ now = rtc_tm_to_time64(&alm.time);

memset(&alm, 0, sizeof alm);
- rtc_time_to_tm(now + TEST_SUSPEND_SECONDS, &alm.time);
+ rtc_time64_to_tm(now + TEST_SUSPEND_SECONDS, &alm.time);
alm.enabled = true;

status = rtc_set_alarm(rtc, &alm);
--
1.9.1

2017-06-20 09:38:44

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 46/51] rtc: test: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-test.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index 3a2da4c..6a460e3 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -13,10 +13,6 @@
#include <linux/rtc.h>
#include <linux/platform_device.h>

-static int test_mmss64;
-module_param(test_mmss64, int, 0644);
-MODULE_PARM_DESC(test_mmss64, "Test struct rtc_class_ops.set_mmss64().");
-
static struct platform_device *test0 = NULL, *test1 = NULL;

static int test_rtc_read_alarm(struct device *dev,
@@ -44,12 +40,6 @@ static int test_rtc_set_mmss64(struct device *dev, time64_t secs)
return 0;
}

-static int test_rtc_set_mmss(struct device *dev, unsigned long secs)
-{
- dev_info(dev, "%s, secs = %lu\n", __func__, secs);
- return 0;
-}
-
static int test_rtc_proc(struct device *dev, struct seq_file *seq)
{
struct platform_device *plat_dev = to_platform_device(dev);
@@ -70,7 +60,7 @@ static int test_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
.read_time = test_rtc_read_time,
.read_alarm = test_rtc_read_alarm,
.set_alarm = test_rtc_set_alarm,
- .set_mmss = test_rtc_set_mmss,
+ .set_mmss64 = test_rtc_set_mmss64,
.alarm_irq_enable = test_rtc_alarm_irq_enable,
};

@@ -111,11 +101,6 @@ static int test_probe(struct platform_device *plat_dev)
int err;
struct rtc_device *rtc;

- if (test_mmss64) {
- test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
- test_rtc_ops.set_mmss = NULL;
- }
-
rtc = devm_rtc_device_register(&plat_dev->dev, "test",
&test_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
--
1.9.1

2017-06-20 09:38:42

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 47/51] rtc: tps6586: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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);
+ 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(&alrm->time, &seconds);
+ seconds = rtc_tm_to_time64(&alrm->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, &alrm->time);
+ rtc_time64_to_tm(seconds, &alrm->time);
return 0;
}

--
1.9.1

2017-06-20 09:39:58

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 50/51] rtc: xgene stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-xgene.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-xgene.c b/drivers/rtc/rtc-xgene.c
index 65b432a..c62b5b6 100644
--- a/drivers/rtc/rtc-xgene.c
+++ b/drivers/rtc/rtc-xgene.c
@@ -58,11 +58,11 @@ static int xgene_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct xgene_rtc_dev *pdata = dev_get_drvdata(dev);

- rtc_time_to_tm(readl(pdata->csr_base + RTC_CCVR), tm);
+ rtc_time64_to_tm(readl(pdata->csr_base + RTC_CCVR), tm);
return rtc_valid_tm(tm);
}

-static int xgene_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int xgene_rtc_set_mmss64(struct device *dev, time64_t secs)
{
struct xgene_rtc_dev *pdata = dev_get_drvdata(dev);

@@ -80,7 +80,7 @@ static int xgene_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct xgene_rtc_dev *pdata = dev_get_drvdata(dev);

- rtc_time_to_tm(pdata->alarm_time, &alrm->time);
+ rtc_time64_to_tm(pdata->alarm_time, &alrm->time);
alrm->enabled = readl(pdata->csr_base + RTC_CCR) & RTC_CCR_IE;

return 0;
@@ -108,10 +108,10 @@ static int xgene_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct xgene_rtc_dev *pdata = dev_get_drvdata(dev);
unsigned long rtc_time;
- unsigned long alarm_time;
+ unsigned long long alarm_time;

rtc_time = readl(pdata->csr_base + RTC_CCVR);
- rtc_tm_to_time(&alrm->time, &alarm_time);
+ alarm_time = rtc_tm_to_time64(&alrm->time);

pdata->alarm_time = alarm_time;
writel((u32) pdata->alarm_time, pdata->csr_base + RTC_CMR);
@@ -123,7 +123,7 @@ static int xgene_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)

static const struct rtc_class_ops xgene_rtc_ops = {
.read_time = xgene_rtc_read_time,
- .set_mmss = xgene_rtc_set_mmss,
+ .set_mmss64 = xgene_rtc_set_mmss64,
.read_alarm = xgene_rtc_read_alarm,
.set_alarm = xgene_rtc_set_alarm,
.alarm_irq_enable = xgene_rtc_alarm_irq_enable,
--
1.9.1

2017-06-20 09:40:20

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 49/51] rtc: wm831x: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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(&new_tm, &new_time);
- if (ret < 0) {
- dev_err(dev, "Failed to convert time: %d\n", ret);
- return ret;
- }
+ new_time = rtc_tm_to_time64(&new_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, &alrm->time);
+ rtc_time64_to_tm(time, &alrm->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(&alrm->time, &time);
- if (ret < 0) {
- dev_err(dev, "Failed to convert time: %d\n", ret);
- return ret;
- }
+ time = rtc_tm_to_time64(&alrm->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

2017-06-20 09:41:06

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 48/51] rtc: vr41xx: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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(&rtc_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

2017-06-20 09:41:04

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 45/51] rtc: tegra stop using rtc deprecated functions

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 <[email protected]>
CC: Thierry Reding <[email protected]>
CC: Jonathan Hunter <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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(&info->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);
+ 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, &alarm->time);
+ rtc_time64_to_tm(sec, &alarm->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(&alarm->time, &sec);
+ sec = rtc_tm_to_time64(&alarm->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

2017-06-20 09:38:32

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 41/51] rtc: stk17ta8: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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

2017-06-20 09:41:55

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 38/51] rtc: sh: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-sh.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 6c2d398..f65da1e 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -694,7 +694,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev)

/* reset rtc to epoch 0 if time is invalid */
if (rtc_read_time(rtc->rtc_dev, &r) < 0) {
- rtc_time_to_tm(0, &r);
+ rtc_time64_to_tm(0, &r);
rtc_set_time(rtc->rtc_dev, &r);
}

--
1.9.1

2017-06-20 09:38:31

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 40/51] rtc: snvs: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-snvs.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index d8ef9e0..774048e 100644
--- a/drivers/rtc/rtc-snvs.c
+++ b/drivers/rtc/rtc-snvs.c
@@ -121,9 +121,9 @@ static int snvs_rtc_enable(struct snvs_rtc_data *data, bool enable)
static int snvs_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct snvs_rtc_data *data = dev_get_drvdata(dev);
- unsigned long time = rtc_read_lp_counter(data);
+ unsigned long long time = rtc_read_lp_counter(data);

- rtc_time_to_tm(time, tm);
+ rtc_time64_to_tm(time, tm);

return 0;
}
@@ -131,9 +131,9 @@ static int snvs_rtc_read_time(struct device *dev, struct rtc_time *tm)
static int snvs_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
struct snvs_rtc_data *data = dev_get_drvdata(dev);
- unsigned long time;
+ unsigned long long time;

- rtc_tm_to_time(tm, &time);
+ time = rtc_tm_to_time64(tm);

/* Disable RTC first */
snvs_rtc_enable(data, false);
@@ -154,7 +154,7 @@ static int snvs_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
u32 lptar, lpsr;

regmap_read(data->regmap, data->offset + SNVS_LPTAR, &lptar);
- rtc_time_to_tm(lptar, &alrm->time);
+ rtc_time64_to_tm((u64)lptar, &alrm->time);

regmap_read(data->regmap, data->offset + SNVS_LPSR, &lpsr);
alrm->pending = (lpsr & SNVS_LPSR_LPTA) ? 1 : 0;
@@ -179,9 +179,9 @@ static int snvs_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct snvs_rtc_data *data = dev_get_drvdata(dev);
struct rtc_time *alrm_tm = &alrm->time;
- unsigned long time;
+ unsigned long long time;

- rtc_tm_to_time(alrm_tm, &time);
+ time = rtc_tm_to_time64(alrm_tm);

regmap_update_bits(data->regmap, data->offset + SNVS_LPCR, SNVS_LPCR_LPTA_EN, 0);
rtc_write_sync_lp(data);
--
1.9.1

2017-06-20 09:42:28

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 43/51] rtc: sun6i: stop using rtc deprecated functions

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 <[email protected]>
CC: Maxime Ripard <[email protected]>
CC: Chen-Yu Tsai <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-sun6i.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index 39cbc12..9928f74 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -120,7 +120,7 @@ struct sun6i_rtc_dev {
struct device *dev;
void __iomem *base;
int irq;
- unsigned long alarm;
+ unsigned long long alarm;

struct clk_hw hw;
struct clk_hw *int_osc;
@@ -342,7 +342,7 @@ static int sun6i_rtc_getalarm(struct device *dev, struct rtc_wkalrm *wkalrm)

wkalrm->enabled = !!(alrm_en & SUN6I_ALRM_EN_CNT_EN);
wkalrm->pending = !!(alrm_st & SUN6I_ALRM_EN_CNT_EN);
- rtc_time_to_tm(chip->alarm, &wkalrm->time);
+ rtc_time64_to_tm(chip->alarm, &wkalrm->time);

return 0;
}
@@ -352,9 +352,9 @@ static int sun6i_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
struct sun6i_rtc_dev *chip = dev_get_drvdata(dev);
struct rtc_time *alrm_tm = &wkalrm->time;
struct rtc_time tm_now;
- unsigned long time_now = 0;
- unsigned long time_set = 0;
- unsigned long time_gap = 0;
+ unsigned long long time_now = 0;
+ unsigned long long time_set = 0;
+ unsigned long long time_gap = 0;
int ret = 0;

ret = sun6i_rtc_gettime(dev, &tm_now);
@@ -363,8 +363,8 @@ static int sun6i_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
return -EINVAL;
}

- rtc_tm_to_time(alrm_tm, &time_set);
- rtc_tm_to_time(&tm_now, &time_now);
+ time_set = rtc_tm_to_time64(alrm_tm);
+ time_now = rtc_tm_to_time64(&tm_now);
if (time_set <= time_now) {
dev_err(dev, "Date to set in the past\n");
return -EINVAL;
--
1.9.1

2017-06-20 09:43:08

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 42/51] rtc: stmp3xxx: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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), &alm->time);
+ rtc_time64_to_tm(readl(rtc_data->io + STMP3XXX_RTC_ALARM), &alm->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(&alm->time, &t);
+ t = rtc_tm_to_time64(&alm->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

2017-06-20 09:38:25

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 29/51] rtc: lpc32xx: stop using rtc deprecated functions

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 <[email protected]>
CC: Vladimir Zapolskiy <[email protected]>
CC: Sylvain Lemieux <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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), &wkalrm->time);
+ rtc_time64_to_tm(rtc_readl(rtc, LPC32XX_RTC_MATCH0), &wkalrm->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(&wkalrm->time, &alarmsecs);
- if (ret < 0) {
- dev_warn(dev, "Failed to convert time: %d\n", ret);
- return ret;
- }
+ alarmsecs = rtc_tm_to_time64(&wkalrm->time);

spin_lock_irq(&rtc->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

2017-06-20 09:43:59

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 39/51] rtc: sirfsoc: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: Barry Song <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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), &rtc_alarm);
+ rtc_alarm = rtc_tm_to_time64(&alrm->time);

spin_lock_irq(&rtcdrv->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, &rtc_time);
+ rtc_time = rtc_tm_to_time64(tm);

rtcdrv->overflow_rtc = rtc_time >> (BITS_PER_LONG - RTC_SHIFT);

--
1.9.1

2017-06-20 09:38:22

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 35/51] rtc: pm8xxx: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-pm8xxx.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index fac8355..e6b52bd 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -81,7 +81,8 @@ struct pm8xxx_rtc {
static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
int rc, i;
- unsigned long secs, irq_flags;
+ unsigned long long secs;
+ unsigned long irq_flags;
u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0;
unsigned int ctrl_reg;
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
@@ -90,14 +91,14 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
if (!rtc_dd->allow_set_time)
return -EACCES;

- rtc_tm_to_time(tm, &secs);
+ secs = rtc_tm_to_time64(tm);

for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) {
value[i] = secs & 0xFF;
secs >>= 8;
}

- dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs);
+ dev_dbg(dev, "Seconds value to be written to RTC = %llu\n", secs);

spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);

@@ -156,7 +157,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
int rc;
u8 value[NUM_8_BIT_RTC_REGS];
- unsigned long secs;
+ unsigned long long secs;
unsigned int reg;
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
@@ -188,7 +189,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)

secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);

- rtc_time_to_tm(secs, tm);
+ rtc_time64_to_tm(secs, tm);

rc = rtc_valid_tm(tm);
if (rc < 0) {
@@ -196,7 +197,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
return rc;
}

- dev_dbg(dev, "secs = %lu, h:m:s == %d:%d:%d, d/m/y = %d/%d/%d\n",
+ dev_dbg(dev, "secs = %llu, h:m:s == %d:%d:%d, d/m/y = %d/%d/%d\n",
secs, tm->tm_hour, tm->tm_min, tm->tm_sec,
tm->tm_mday, tm->tm_mon, tm->tm_year);

@@ -208,11 +209,12 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
int rc, i;
u8 value[NUM_8_BIT_RTC_REGS];
unsigned int ctrl_reg;
- unsigned long secs, irq_flags;
+ unsigned long long secs;
+ unsigned long irq_flags;
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;

- rtc_tm_to_time(&alarm->time, &secs);
+ secs = rtc_tm_to_time64(&alarm->time);

for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) {
value[i] = secs & 0xFF;
@@ -256,7 +258,7 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
int rc;
u8 value[NUM_8_BIT_RTC_REGS];
- unsigned long secs;
+ unsigned long long secs;
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;

@@ -269,7 +271,7 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)

secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);

- rtc_time_to_tm(secs, &alarm->time);
+ rtc_time64_to_tm(secs, &alarm->time);

rc = rtc_valid_tm(&alarm->time);
if (rc < 0) {
--
1.9.1

2017-06-20 09:44:48

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 34/51] rtc: pl031: stop using rtc deprecated functions

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 <[email protected]>
CC: Linus Walleij <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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, &time);
- rtc_time_to_tm(time, &calc_tm);
+ time = rtc_tm_to_time64(tm);
+ rtc_time64_to_tm(time, &calc_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, &time);

- 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), &alarm->time);
+ rtc_time64_to_tm(readl(ldata->base + RTC_MR), &alarm->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(&alarm->time);
if (ret == 0) {
- ret = rtc_tm_to_time(&alarm->time, &time);
- if (ret == 0) {
- writel(time, ldata->base + RTC_MR);
- pl031_alarm_irq_enable(dev, alarm->enabled);
- }
+ time = rtc_tm_to_time64(&alarm->time);
+ writel(time, ldata->base + RTC_MR);
+ pl031_alarm_irq_enable(dev, alarm->enabled);
}

return ret;
--
1.9.1

2017-06-20 09:38:20

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 32/51] rtc: pcap: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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 = &alrm->time;
- unsigned long secs;
+ unsigned long long secs;
u32 tod; /* time of day, seconds since midnight */
u32 days; /* days since 1/1/1970 */

@@ -56,7 +56,7 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days);
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;

- rtc_time_to_tm(secs, tm);
+ rtc_time64_to_tm(secs, tm);

return 0;
}
@@ -66,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 = &alrm->time;
- unsigned long secs;
+ unsigned long long secs;
u32 tod, days;

- rtc_tm_to_time(tm, &secs);
+ 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, &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, &days);
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;

- rtc_time_to_tm(secs, tm);
+ rtc_time64_to_tm(secs, tm);

return rtc_valid_tm(tm);
}

-static int pcap_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int pcap_rtc_set_mmss64(struct device *dev, time64_t secs)
{
struct platform_device *pdev = to_platform_device(dev);
struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev);
@@ -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

2017-06-20 09:45:16

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 37/51] rtc: sa1100: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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, &time);
- 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(&info->lock);
- ret = rtc_tm_to_time(&alrm->time, &time);
- if (ret != 0)
- goto out;
+ time = rtc_tm_to_time64(&alrm->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(&info->lock);

- return ret;
+ return 0;
}

static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)
--
1.9.1

2017-06-20 09:46:20

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 36/51] rtc: rs5c348: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-rs5c348.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c
index 9a30698..f82c0bc 100644
--- a/drivers/rtc/rtc-rs5c348.c
+++ b/drivers/rtc/rtc-rs5c348.c
@@ -137,7 +137,7 @@ struct rs5c348_plat_data {

if (rtc_valid_tm(tm) < 0) {
dev_err(&spi->dev, "retrieved date/time is not valid.\n");
- rtc_time_to_tm(0, tm);
+ rtc_time64_to_tm(0, tm);
}

return 0;
@@ -183,7 +183,7 @@ static int rs5c348_probe(struct spi_device *spi)
dev_warn(&spi->dev, "voltage-low detected.\n");
if (ret & RS5C348_BIT_XSTP)
dev_warn(&spi->dev, "oscillator-stop detected.\n");
- rtc_time_to_tm(0, &tm); /* 1970/1/1 */
+ rtc_time64_to_tm(0, &tm); /* 1970/1/1 */
ret = rs5c348_rtc_set_time(&spi->dev, &tm);
if (ret < 0)
goto kfree_exit;
--
1.9.1

2017-06-20 09:46:49

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 33/51] rtc: pl030: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-pl030.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index f85a1a9..c917051 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -39,24 +39,26 @@ static int pl030_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct pl030_rtc *rtc = dev_get_drvdata(dev);

- rtc_time_to_tm(readl(rtc->base + RTC_MR), &alrm->time);
+ rtc_time64_to_tm(readl(rtc->base + RTC_MR), &alrm->time);
return 0;
}

static int pl030_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct pl030_rtc *rtc = 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(&alrm->time);
- if (ret == 0)
- ret = rtc_tm_to_time(&alrm->time, &time);
- if (ret == 0)
- writel(time, rtc->base + RTC_MR);
+ if (ret)
+ return ret;
+
+ time = rtc_tm_to_time64(&alrm->time);
+ writel(time, rtc->base + RTC_MR);
+
return ret;
}

@@ -64,7 +66,7 @@ static int pl030_read_time(struct device *dev, struct rtc_time *tm)
{
struct pl030_rtc *rtc = dev_get_drvdata(dev);

- rtc_time_to_tm(readl(rtc->base + RTC_DR), tm);
+ rtc_time64_to_tm(readl(rtc->base + RTC_DR), tm);

return 0;
}
@@ -81,13 +83,11 @@ static int pl030_set_time(struct device *dev, struct rtc_time *tm)
{
struct pl030_rtc *rtc = dev_get_drvdata(dev);
unsigned long time;
- int ret;

- ret = rtc_tm_to_time(tm, &time);
- if (ret == 0)
- writel(time + 1, rtc->base + RTC_LR);
+ time = rtc_tm_to_time64(tm);
+ writel(time + 1, rtc->base + RTC_LR);

- return ret;
+ return 0;
}

static const struct rtc_class_ops pl030_ops = {
--
1.9.1

2017-06-20 09:38:15

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 27/51] rtc: imxdi: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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, &alarm->time);
+ rtc_time64_to_tm((u64)dcamr, &alarm->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(&alarm->time, &alarm_time);
- if (rc)
- return rc;
+ alarm_time = rtc_tm_to_time64(&alarm->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

2017-06-20 09:47:25

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 31/51] rtc: omap: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-omap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 13f7cd1..8aa3957 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -432,7 +432,7 @@ static void omap_rtc_power_off(void)
{
struct omap_rtc *rtc = omap_rtc_power_off_rtc;
struct rtc_time tm;
- unsigned long now;
+ unsigned long long now;
u32 val;

rtc->type->unlock(rtc);
@@ -443,8 +443,8 @@ static void omap_rtc_power_off(void)
/* set alarm two seconds from now */
omap_rtc_read_time_raw(rtc, &tm);
bcd2tm(&tm);
- rtc_tm_to_time(&tm, &now);
- rtc_time_to_tm(now + 2, &tm);
+ now = rtc_tm_to_time64(&tm);
+ rtc_time64_to_tm(now + 2, &tm);

if (tm2bcd(&tm) < 0) {
dev_err(&rtc->rtc->dev, "power off failed\n");
--
1.9.1

2017-06-20 09:48:16

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 30/51] rtc: mv: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-mv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c
index 79bb286..fce4658 100644
--- a/drivers/rtc/rtc-mv.c
+++ b/drivers/rtc/rtc-mv.c
@@ -127,7 +127,7 @@ static int mv_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)

if (rtc_valid_tm(&alm->time) < 0) {
dev_err(dev, "retrieved alarm date/time is not valid.\n");
- rtc_time_to_tm(0, &alm->time);
+ rtc_time64_to_tm(0, &alm->time);
}

alm->enabled = !!readl(ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
--
1.9.1

2017-06-20 09:48:51

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 28/51] rtc: jz4740: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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, &alrm->time);
+ rtc_time64_to_tm((u64)secs, &alrm->time);

return rtc_valid_tm(&alrm->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(&alrm->time, &secs);
+ secs = rtc_tm_to_time64(&alrm->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

2017-06-20 09:48:49

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 26/51] rtc: gemini: stop using rtc deprecated functions

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 <[email protected]>
CC: Hans Ulli Kroll <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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);
+ 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

2017-06-20 09:51:19

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 18/51] rtc: dm355evm: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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);
+ value = rtc_tm_to_time64(tm);
time.value = cpu_to_le32(value);

dev_dbg(dev, "write timestamp %08x\n", time.value);
--
1.9.1

2017-06-20 09:37:59

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 19/51] rtc: ds1305: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-ds1305.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c
index 72b2293..b41168b 100644
--- a/drivers/rtc/rtc-ds1305.c
+++ b/drivers/rtc/rtc-ds1305.c
@@ -324,23 +324,20 @@ static int ds1305_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
{
struct ds1305 *ds1305 = dev_get_drvdata(dev);
struct spi_device *spi = ds1305->spi;
- unsigned long now, later;
+ unsigned long long now, later;
struct rtc_time tm;
int status;
u8 buf[1 + DS1305_ALM_LEN];

/* convert desired alarm to time_t */
- status = rtc_tm_to_time(&alm->time, &later);
- if (status < 0)
- return status;
+ later = rtc_tm_to_time64(&alm->time);

/* Read current time as time_t */
status = ds1305_get_time(dev, &tm);
if (status < 0)
return status;
- status = rtc_tm_to_time(&tm, &now);
- if (status < 0)
- return status;
+
+ now = rtc_tm_to_time64(&tm);

/* make sure alarm fires within the next 24 hours */
if (later <= now)
--
1.9.1

2017-06-20 09:37:58

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 23/51] rtc: ds1672: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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(&client->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

2017-06-20 09:52:08

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 21/51] rtc: ds1511: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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

2017-06-20 09:37:52

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 20/51] rtc: ds1374: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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, &itime, 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);
+ itime = rtc_tm_to_time64(time);
return ds1374_write_rtc(client, itime, DS1374_REG_TOD0, 4);
}

--
1.9.1

2017-06-20 09:37:35

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 12/51] rtc: coh901331: stop using rtc deprecated functions

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 <[email protected]>
CC: Linus Walleij <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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), &alarm->time);
+ rtc_time64_to_tm(
+ (u64)readl(rtap->virtbase + COH901331_ALARM), &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(&alarm->time, &time);
+ time = rtc_tm_to_time64(&alarm->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

2017-06-20 09:37:34

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 15/51] rtc: da9063: stop using rtc deprecated functions

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 <[email protected]>
CC: Support Opensource <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-da9063.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-da9063.c b/drivers/rtc/rtc-da9063.c
index f85cae2..c0e140d 100644
--- a/drivers/rtc/rtc-da9063.c
+++ b/drivers/rtc/rtc-da9063.c
@@ -227,8 +227,8 @@ static int da9063_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct da9063_compatible_rtc *rtc = dev_get_drvdata(dev);
const struct da9063_compatible_rtc_regmap *config = rtc->config;
- unsigned long tm_secs;
- unsigned long al_secs;
+ unsigned long long tm_secs;
+ unsigned long long al_secs;
u8 data[RTC_DATA_LEN];
int ret;

@@ -247,8 +247,8 @@ static int da9063_rtc_read_time(struct device *dev, struct rtc_time *tm)

da9063_data_to_tm(data, tm, rtc);

- rtc_tm_to_time(tm, &tm_secs);
- rtc_tm_to_time(&rtc->alarm_time, &al_secs);
+ tm_secs = rtc_tm_to_time64(tm);
+ al_secs = rtc_tm_to_time64(&rtc->alarm_time);

/* handle the rtc synchronisation delay */
if (rtc->rtc_sync == true && al_secs - tm_secs == 1)
--
1.9.1

2017-06-20 09:55:13

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 16/51] rtc: davinci: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-davinci.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c
index caf3556..03beba3 100644
--- a/drivers/rtc/rtc-davinci.c
+++ b/drivers/rtc/rtc-davinci.c
@@ -429,18 +429,18 @@ static int davinci_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
if (alm->time.tm_mday <= 0 && alm->time.tm_mon < 0
&& alm->time.tm_year < 0) {
struct rtc_time tm;
- unsigned long now, then;
+ unsigned long long now, then;

davinci_rtc_read_time(dev, &tm);
- rtc_tm_to_time(&tm, &now);
+ now = rtc_tm_to_time64(&tm);

alm->time.tm_mday = tm.tm_mday;
alm->time.tm_mon = tm.tm_mon;
alm->time.tm_year = tm.tm_year;
- rtc_tm_to_time(&alm->time, &then);
+ then = rtc_tm_to_time64(&alm->time);

if (then < now) {
- rtc_time_to_tm(now + 24 * 60 * 60, &tm);
+ rtc_time64_to_tm(now + 24 * 60 * 60, &tm);
alm->time.tm_mday = tm.tm_mday;
alm->time.tm_mon = tm.tm_mon;
alm->time.tm_year = tm.tm_year;
--
1.9.1

2017-06-20 09:55:51

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 10/51] rtc: at91sam9: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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, &secs);
- 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 = &alrm->time;
- unsigned long secs;
+ unsigned long long secs;
u32 offset;
u32 mr;
- int err;

- err = rtc_tm_to_time(tm, &secs);
- if (err != 0)
- return err;
+ secs = rtc_tm_to_time64(tm);

offset = gpbr_readl(rtc);
if (offset == 0) {
--
1.9.1

2017-06-20 09:37:26

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions

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 <[email protected]>
CC: Support Opensource <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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, &alm_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

2017-06-20 09:56:32

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 09/51] rtc: at32ap700x: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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, &now);
- 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(&rtc->lock);
- rtc_time_to_tm(rtc->alarm_time, &alrm->time);
+ rtc_time64_to_tm(rtc->alarm_time, &alrm->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(&rtc->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(&alrm->time, &alarm_unix_time);
- if (ret)
- return ret;
+ alarm_unix_time = rtc_tm_to_time64(&alrm->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(&rtc->lock);

- return ret;
+ return 0;
}

static int at32_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
--
1.9.1

2017-06-20 09:37:18

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 08/51] rtc: armada38x: stop using rtc deprecated functions

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 <[email protected]>
CC: Jason Cooper <[email protected]>
CC: Gregory Clement <[email protected]>
CC: Sebastian Hesselbarth <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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(&rtc->lock, flags);
time = rtc->data->read_rtc_reg(rtc, RTC_TIME);
spin_unlock_irqrestore(&rtc->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, &time);
+ unsigned long long time;
+ unsigned long flags;

- if (ret)
- goto out;
+ time = rtc_tm_to_time64(tm);

spin_lock_irqsave(&rtc->lock, flags);
rtc_delayed_write(time, rtc, RTC_TIME);
spin_unlock_irqrestore(&rtc->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(&rtc->lock, flags);

alrm->enabled = val ? 1 : 0;
- rtc_time_to_tm(time, &alrm->time);
+ rtc_time64_to_tm(time, &alrm->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(&alrm->time, &time);
+ unsigned long long time;
+ unsigned long flags;

- if (ret)
- goto out;
+ time = rtc_tm_to_time64(&alrm->time);

spin_lock_irqsave(&rtc->lock, flags);

@@ -288,8 +283,7 @@ static int armada38x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)

spin_unlock_irqrestore(&rtc->lock, flags);

-out:
- return ret;
+ return 0;
}

static int armada38x_rtc_alarm_irq_enable(struct device *dev,
--
1.9.1

2017-06-20 09:57:09

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 07/51] rtc: ab8500: stop using rtc deprecated functions

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 <[email protected]>
CC: Linus Walleij <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
---
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(&tm, &secs);
+ secs = rtc_tm_to_time64(&tm);
return secs;
}

@@ -89,7 +89,7 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
unsigned long timeout = jiffies + HZ;
int retval, i;
- unsigned long mins, secs;
+ unsigned long long mins, secs;
unsigned char buf[ARRAY_SIZE(ab8500_rtc_time_regs)];
u8 value;

@@ -130,7 +130,7 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
/* Add back the initially subtracted number of seconds */
secs += get_elapsed_seconds(AB8500_RTC_EPOCH);

- rtc_time_to_tm(secs, tm);
+ rtc_time64_to_tm(secs, tm);
return rtc_valid_tm(tm);
}

@@ -138,7 +138,7 @@ static int ab8500_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
int retval, i;
unsigned char buf[ARRAY_SIZE(ab8500_rtc_time_regs)];
- unsigned long no_secs, no_mins, secs = 0;
+ unsigned long long no_secs, 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);
+ 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, &alarm->time);
+ rtc_time64_to_tm(secs, &alarm->time);

return rtc_valid_tm(&alarm->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(&alarm->time, &secs);
+ secs = rtc_tm_to_time64(&alarm->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, &curtm); /* Read current time */
- rtc_tm_to_time(&curtm, &cursec);
+ cursec = rtc_tm_to_time64(&curtm);
if ((secs - cursec) < 59) {
dev_dbg(dev, "Alarm less than 1 minute not supported\r\n");
return -EINVAL;
@@ -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 (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) {
dev_dbg(dev, "year should be equal to or greater than %d\n",
@@ -290,7 +290,7 @@ static int ab8540_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
}

/* Get the number of seconds since 1970 */
- rtc_tm_to_time(&alarm->time, &secs);
+ secs = rtc_tm_to_time64(&alarm->time);

/*
* Convert it to the number of seconds since 01-01-2000 00:00:00
--
1.9.1

2017-06-20 09:57:50

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 06/51] rtc: ab-b5ze-s3: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/rtc/rtc-ab-b5ze-s3.c | 45 +++++++++++++-------------------------------
1 file changed, 13 insertions(+), 32 deletions(-)

diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
index a319bf1..ce37997 100644
--- a/drivers/rtc/rtc-ab-b5ze-s3.c
+++ b/drivers/rtc/rtc-ab-b5ze-s3.c
@@ -328,7 +328,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev,
struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
struct rtc_time rtc_tm, *alarm_tm = &alarm->time;
u8 regs[ABB5ZES3_TIMA_SEC_LEN + 1];
- unsigned long rtc_secs;
+ unsigned long long rtc_secs;
unsigned int reg;
u8 timer_secs;
int ret;
@@ -352,9 +352,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev,
goto err;

/* ... convert to seconds ... */
- ret = rtc_tm_to_time(&rtc_tm, &rtc_secs);
- if (ret)
- goto err;
+ rtc_secs = rtc_tm_to_time64(&rtc_tm);

/* ... add remaining timer A time ... */
ret = sec_from_timer_a(&timer_secs, regs[1], regs[2]);
@@ -362,7 +360,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev,
goto err;

/* ... and convert back. */
- rtc_time_to_tm(rtc_secs + timer_secs, alarm_tm);
+ rtc_time64_to_tm(rtc_secs + timer_secs, alarm_tm);

ret = regmap_read(data->regmap, ABB5ZES3_REG_CTRL2, &reg);
if (ret) {
@@ -383,7 +381,7 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev,
{
struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
struct rtc_time rtc_tm, *alarm_tm = &alarm->time;
- unsigned long rtc_secs, alarm_secs;
+ unsigned long long rtc_secs, alarm_secs;
u8 regs[ABB5ZES3_ALRM_SEC_LEN];
unsigned int reg;
int ret;
@@ -414,13 +412,8 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev,
alarm_tm->tm_year = rtc_tm.tm_year;
alarm_tm->tm_mon = rtc_tm.tm_mon;

- ret = rtc_tm_to_time(&rtc_tm, &rtc_secs);
- if (ret)
- goto err;
-
- ret = rtc_tm_to_time(alarm_tm, &alarm_secs);
- if (ret)
- goto err;
+ rtc_secs = rtc_tm_to_time64(&rtc_tm);
+ alarm_secs = rtc_tm_to_time64(alarm_tm);

if (alarm_secs < rtc_secs) {
if (alarm_tm->tm_mon == 11) {
@@ -477,7 +470,7 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
struct rtc_time *alarm_tm = &alarm->time;
- unsigned long rtc_secs, alarm_secs;
+ unsigned long long rtc_secs, alarm_secs;
u8 regs[ABB5ZES3_ALRM_SEC_LEN];
struct rtc_time rtc_tm;
int ret, enable = 1;
@@ -486,13 +479,8 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
if (ret)
goto err;

- ret = rtc_tm_to_time(&rtc_tm, &rtc_secs);
- if (ret)
- goto err;
-
- ret = rtc_tm_to_time(alarm_tm, &alarm_secs);
- if (ret)
- goto err;
+ rtc_secs = rtc_tm_to_time64(&rtc_tm);
+ alarm_secs = rtc_tm_to_time64(alarm_tm);

/* If alarm time is before current time, disable the alarm */
if (!alarm->enabled || alarm_secs <= rtc_secs) {
@@ -511,9 +499,7 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
rtc_tm.tm_mon += 1;
}

- ret = rtc_tm_to_time(&rtc_tm, &rtc_secs);
- if (ret)
- goto err;
+ rtc_secs = rtc_tm_to_time64(&rtc_tm);

if (alarm_secs > rtc_secs) {
dev_err(dev, "%s: alarm maximum is one month in the "
@@ -597,7 +583,7 @@ static int abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
struct rtc_time *alarm_tm = &alarm->time;
- unsigned long rtc_secs, alarm_secs;
+ unsigned long long rtc_secs, alarm_secs;
struct rtc_time rtc_tm;
int ret;

@@ -606,13 +592,8 @@ static int abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
if (ret)
goto err;

- ret = rtc_tm_to_time(&rtc_tm, &rtc_secs);
- if (ret)
- goto err;
-
- ret = rtc_tm_to_time(alarm_tm, &alarm_secs);
- if (ret)
- goto err;
+ rtc_secs = rtc_tm_to_time64(&rtc_tm);
+ alarm_secs = rtc_tm_to_time64(alarm_tm);

/* Let's first disable both the alarm and the timer interrupts */
ret = _abb5zes3_rtc_update_alarm(dev, false);
--
1.9.1

2017-06-20 09:37:06

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 01/51] x86: rtc: stop using rtc deprecated functions

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 <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: [email protected]
CC: John Stultz <[email protected]>
CC: [email protected]
---
arch/x86/kernel/rtc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 5b21cb7..76b817c 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -40,11 +40,11 @@
*/
int mach_set_rtc_mmss(const struct timespec *now)
{
- unsigned long nowtime = now->tv_sec;
+ unsigned long long nowtime = now->tv_sec;
struct rtc_time tm;
int retval = 0;

- rtc_time_to_tm(nowtime, &tm);
+ rtc_time64_to_tm(nowtime, &tm);
if (!rtc_valid_tm(&tm)) {
retval = mc146818_set_time(&tm);
if (retval)
@@ -52,7 +52,7 @@ int mach_set_rtc_mmss(const struct timespec *now)
__func__, retval);
} else {
printk(KERN_ERR
- "%s: Invalid RTC value: write of %lx to RTC failed\n",
+ "%s: Invalid RTC value: write of %llx to RTC failed\n",
__func__, nowtime);
retval = -EINVAL;
}
--
1.9.1

2017-06-20 09:58:35

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 05/51] rtc: 88pm860x: stop using rtc deprecated functions

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 <[email protected]>
CC: Alessandro Zummo <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
---
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, &now_time);
- rtc_tm_to_time(next, &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);
+ 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, &alrm->time);
+ rtc_time64_to_tm(ticks, &alrm->time);
ret = pm860x_reg_read(info->i2c, PM8607_RTC1);
alrm->enabled = (ret & ALARM_EN) ? 1 : 0;
alrm->pending = (ret & (ALARM | ALARM_WAKEUP)) ? 1 : 0;
@@ -189,7 +189,7 @@ static int pm860x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct pm860x_rtc_info *info = dev_get_drvdata(dev);
struct rtc_time now_tm, alarm_tm;
- unsigned long ticks, base, data;
+ unsigned long long ticks, base, data;
unsigned char buf[8];
int mask;

@@ -204,13 +204,13 @@ static int pm860x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
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, &now_tm);
+ rtc_time64_to_tm(ticks, &now_tm);
rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
/* get new ticks for alarm in 24 hours */
- rtc_tm_to_time(&alarm_tm, &ticks);
+ ticks = rtc_tm_to_time64(&alarm_tm);
data = ticks - base;

buf[0] = data & 0xff;
@@ -314,7 +314,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
struct pm860x_rtc_pdata *pdata = NULL;
struct pm860x_rtc_info *info;
struct rtc_time tm;
- unsigned long ticks = 0;
+ unsigned long long ticks = 0;
int ret;

pdata = dev_get_platdata(&pdev->dev);
@@ -367,7 +367,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
return ret;
}
}
- rtc_tm_to_time(&tm, &ticks);
+ ticks = rtc_tm_to_time64(&tm);
if (pm860x_rtc_dt_init(pdev, info)) {
if (pdata && pdata->sync) {
pdata->sync(ticks);
--
1.9.1

2017-06-20 10:01:03

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 03/51] net: broadcom: stop using rtc deprecated functions

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 <[email protected]>
CC: Michael Chan <[email protected]>
CC: [email protected]
CC: [email protected]
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index b56c54d..9fef202 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4703,7 +4703,7 @@ int bnxt_hwrm_fw_set_time(struct bnxt *bp)
return -EOPNOTSUPP;

do_gettimeofday(&tv);
- rtc_time_to_tm(tv.tv_sec, &tm);
+ rtc_time64_to_tm(tv.tv_sec, &tm);
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_SET_TIME, -1, -1);
req.year = cpu_to_le16(1900 + tm.tm_year);
req.month = 1 + tm.tm_mon;
--
1.9.1

2017-06-20 10:01:59

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 02/51] x86: intel-mid: vrtc: stop using rtc deprecated functions

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 <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: [email protected]
CC: [email protected]
---
arch/x86/platform/intel-mid/intel_mid_vrtc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/platform/intel-mid/intel_mid_vrtc.c b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
index 5802486..a177081 100644
--- a/arch/x86/platform/intel-mid/intel_mid_vrtc.c
+++ b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
@@ -94,7 +94,7 @@ int vrtc_set_mmss(const struct timespec *now)
int year;
int retval = 0;

- rtc_time_to_tm(now->tv_sec, &tm);
+ rtc_time64_to_tm(now->tv_sec, &tm);
if (!rtc_valid_tm(&tm) && tm.tm_year >= 72) {
/*
* tm.year is the number of years since 1900, and the
--
1.9.1

2017-06-20 10:03:55

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

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.


> 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 +++++-----
> drivers/rtc/rtc-jz4740.c | 12 ++++----
> drivers/rtc/rtc-lpc32xx.c | 19 +++++-------
> drivers/rtc/rtc-mv.c | 2 +-
> drivers/rtc/rtc-omap.c | 6 ++--
> drivers/rtc/rtc-pcap.c | 16 +++++-----
> drivers/rtc/rtc-pl030.c | 24 +++++++--------
> drivers/rtc/rtc-pl031.c | 31 ++++++++-----------
> drivers/rtc/rtc-pm8xxx.c | 22 +++++++-------
> drivers/rtc/rtc-rs5c348.c | 4 +--
> drivers/rtc/rtc-sa1100.c | 25 +++++++---------
> drivers/rtc/rtc-sh.c | 2 +-
> drivers/rtc/rtc-sirfsoc.c | 18 +++++------
> drivers/rtc/rtc-snvs.c | 14 ++++-----
> drivers/rtc/rtc-stk17ta8.c | 2 +-
> drivers/rtc/rtc-stmp3xxx.c | 12 ++++----
> drivers/rtc/rtc-sun6i.c | 14 ++++-----
> drivers/rtc/rtc-sysfs.c | 25 ++++++++--------
> drivers/rtc/rtc-tegra.c | 22 +++++++-------
> drivers/rtc/rtc-test.c | 17 +----------
> drivers/rtc/rtc-tps6586x.c | 26 ++++++++--------
> drivers/rtc/rtc-vr41xx.c | 6 ++--
> drivers/rtc/rtc-wm831x.c | 28 +++++++----------
> drivers/rtc/rtc-xgene.c | 12 ++++----
> kernel/power/suspend_test.c | 6 ++--
> 51 files changed, 342 insertions(+), 420 deletions(-)
>
> --
> CC: [email protected]
> CC: Alessandro Zummo <[email protected]>
> CC: Alexandre Belloni <[email protected]>
> CC: Gregory Clement <[email protected]>
> CC: Ingo Molnar <[email protected]>
> CC: Jason Cooper <[email protected]>
> CC: John Stultz <[email protected]>
> CC: [email protected]
> CC: [email protected]
> CC: Linus Walleij <[email protected]>
> CC: Michael Chan <[email protected]>
> CC: [email protected]
> CC: [email protected]
> CC: Sebastian Hesselbarth <[email protected]>
> CC: Support Opensource <[email protected]>
> CC: Thomas Gleixner <[email protected]>
> CC: [email protected]
> CC: Baruch Siach <[email protected]>
> CC: Hans Ulli Kroll <[email protected]>
> CC: Vladimir Zapolskiy <[email protected]>
> CC: Sylvain Lemieux <[email protected]>
> CC: Barry Song <[email protected]>
> CC: Maxime Ripard <[email protected]>
> CC: Chen-Yu Tsai <[email protected]>
> CC: Thierry Reding <[email protected]>
> CC: Jonathan Hunter <[email protected]>
> CC: [email protected]
> CC: [email protected]
> CC: "Rafael J. Wysocki" <[email protected]>
> CC: Pavel Machek <[email protected]>
> CC: Len Brown <[email protected]>
> CC: [email protected]
>
> 1.9.1
>

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

2017-06-20 10:08:03

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On 20/06/2017 at 12:03:48 +0200, 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.
>

Just to be clear, it is fine on your ST hardware because it uses a 64bit
counter. Most of the one you patched are using 32 bit counters and so
will break anyway.

>
> > 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 +++++-----
> > drivers/rtc/rtc-jz4740.c | 12 ++++----
> > drivers/rtc/rtc-lpc32xx.c | 19 +++++-------
> > drivers/rtc/rtc-mv.c | 2 +-
> > drivers/rtc/rtc-omap.c | 6 ++--
> > drivers/rtc/rtc-pcap.c | 16 +++++-----
> > drivers/rtc/rtc-pl030.c | 24 +++++++--------
> > drivers/rtc/rtc-pl031.c | 31 ++++++++-----------
> > drivers/rtc/rtc-pm8xxx.c | 22 +++++++-------
> > drivers/rtc/rtc-rs5c348.c | 4 +--
> > drivers/rtc/rtc-sa1100.c | 25 +++++++---------
> > drivers/rtc/rtc-sh.c | 2 +-
> > drivers/rtc/rtc-sirfsoc.c | 18 +++++------
> > drivers/rtc/rtc-snvs.c | 14 ++++-----
> > drivers/rtc/rtc-stk17ta8.c | 2 +-
> > drivers/rtc/rtc-stmp3xxx.c | 12 ++++----
> > drivers/rtc/rtc-sun6i.c | 14 ++++-----
> > drivers/rtc/rtc-sysfs.c | 25 ++++++++--------
> > drivers/rtc/rtc-tegra.c | 22 +++++++-------
> > drivers/rtc/rtc-test.c | 17 +----------
> > drivers/rtc/rtc-tps6586x.c | 26 ++++++++--------
> > drivers/rtc/rtc-vr41xx.c | 6 ++--
> > drivers/rtc/rtc-wm831x.c | 28 +++++++----------
> > drivers/rtc/rtc-xgene.c | 12 ++++----
> > kernel/power/suspend_test.c | 6 ++--
> > 51 files changed, 342 insertions(+), 420 deletions(-)
> >
> > --
> > CC: [email protected]
> > CC: Alessandro Zummo <[email protected]>
> > CC: Alexandre Belloni <[email protected]>
> > CC: Gregory Clement <[email protected]>
> > CC: Ingo Molnar <[email protected]>
> > CC: Jason Cooper <[email protected]>
> > CC: John Stultz <[email protected]>
> > CC: [email protected]
> > CC: [email protected]
> > CC: Linus Walleij <[email protected]>
> > CC: Michael Chan <[email protected]>
> > CC: [email protected]
> > CC: [email protected]
> > CC: Sebastian Hesselbarth <[email protected]>
> > CC: Support Opensource <[email protected]>
> > CC: Thomas Gleixner <[email protected]>
> > CC: [email protected]
> > CC: Baruch Siach <[email protected]>
> > CC: Hans Ulli Kroll <[email protected]>
> > CC: Vladimir Zapolskiy <[email protected]>
> > CC: Sylvain Lemieux <[email protected]>
> > CC: Barry Song <[email protected]>
> > CC: Maxime Ripard <[email protected]>
> > CC: Chen-Yu Tsai <[email protected]>
> > CC: Thierry Reding <[email protected]>
> > CC: Jonathan Hunter <[email protected]>
> > CC: [email protected]
> > CC: [email protected]
> > CC: "Rafael J. Wysocki" <[email protected]>
> > CC: Pavel Machek <[email protected]>
> > CC: Len Brown <[email protected]>
> > CC: [email protected]
> >
> > 1.9.1
> >
>
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

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

2017-06-20 12:10:16

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

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


Attachments:
(No filename) (760.00 B)
signature.asc (181.00 B)
Digital signature
Download all attachments

2017-06-20 12:10:38

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 51/51] power: suspend test: stop using rtc deprecated functions

On Tue 2017-06-20 11:35:59, Benjamin Gaignard wrote:
> rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they
> rely on 32bits variables and that will make rtc break in y2038/2016.
> Stop using those two functions to safer 64bits ones.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: "Rafael J. Wysocki" <[email protected]>

Acked-by: Pavel Machek <[email protected]>

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


Attachments:
(No filename) (538.00 B)
signature.asc (181.00 B)
Digital signature
Download all attachments

2017-06-20 12:24:17

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

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.

And yes, on PC, they will break in 2100, other in 2106, some in 2070.
I've delayed the tree wide patching until I manage to finish reworking
the infrastructure needed to handle the limits of the RTCs.


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

2017-06-20 13:26:26

by Pavel Machek

[permalink] [raw]
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.

> And yes, on PC, they will break in 2100, other in 2106, some in 2070.
> I've delayed the tree wide patching until I manage to finish reworking
> the infrastructure needed to handle the limits of the RTCs.

Kernel does not know if it has working RTC or not, so it should use
64bit variables. Merging this -- does not hide anything. Yes, some
drivers still may have problems -- so we fix the drivers.

You said:

> > > rtc_time_to_tm will be able to catch it but the 64 bit will
> > > silently ignore it.

If that's the case, we may need 64bit version to be smarter.. but
we'll still need 64bit variables in the kernel.
Pavel

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


Attachments:
(No filename) (1.82 kB)
signature.asc (181.00 B)
Digital signature
Download all attachments

2017-06-20 13:37:38

by Steve Twiss

[permalink] [raw]
Subject: RE: [PATCH 00/51] rtc: stop using rtc deprecated functions

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/

Regards,
Steve

2017-06-20 13:41:07

by Steve Twiss

[permalink] [raw]
Subject: RE: [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions

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.

> 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, &alm_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.

Regards,
Steve

2017-06-20 13:45:06

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

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.

Pavel

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


Attachments:
(No filename) (1.73 kB)
signature.asc (181.00 B)
Digital signature
Download all attachments

2017-06-20 13:48:32

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

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

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


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

2017-06-20 14:18:08

by Benjamin Gaignard

[permalink] [raw]
Subject: Re: [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions

2017-06-20 15:41 GMT+02:00 Steve Twiss <[email protected]>:
> 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, &alm_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
>

2017-06-20 15:07:50

by Benjamin Gaignard

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

2017-06-20 15:48 GMT+02:00 Alexandre Belloni
<[email protected]>:
> 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

2017-06-20 16:06:11

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 07/51] rtc: ab8500: stop using rtc deprecated functions

On Tue, Jun 20, 2017 at 11:35 AM, Benjamin Gaignard
<[email protected]> wrote:

> rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they
> rely on 32bits variables and that will make rtc break in y2038/2016.
> Stop using those two functions to safer 64bits ones.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Linus Walleij <[email protected]>
> CC: Alessandro Zummo <[email protected]>
> CC: Alexandre Belloni <[email protected]>
> CC: [email protected]
> CC: [email protected]
> CC: [email protected]

Looks fine.
Acked-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2017-06-20 16:08:02

by Linus Walleij

[permalink] [raw]
Subject: Re: [rtc-linux] [PATCH 12/51] rtc: coh901331: stop using rtc deprecated functions

On Tue, Jun 20, 2017 at 11:35 AM, Benjamin Gaignard
<[email protected]> wrote:

> rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they
> rely on 32bits variables and that will make rtc break in y2038/2016.
> Stop using those two functions to safer 64bits ones.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Linus Walleij <[email protected]>
> CC: Alessandro Zummo <[email protected]>
> CC: Alexandre Belloni <[email protected]>
> CC: [email protected]
> CC: [email protected]
> CC: [email protected]

Acked-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2017-06-20 16:08:51

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 34/51] rtc: pl031: stop using rtc deprecated functions

On Tue, Jun 20, 2017 at 11:35 AM, Benjamin Gaignard
<[email protected]> wrote:

> rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they
> rely on 32bits variables and that will make rtc break in y2038/2016.
> Stop using those two functions to safer 64bits ones.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Linus Walleij <[email protected]>
> CC: Alessandro Zummo <[email protected]>
> CC: Alexandre Belloni <[email protected]>
> CC: [email protected]
> CC: [email protected]
> CC: [email protected]

Acked-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2017-06-20 21:06:15

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 34/51] rtc: pl031: stop using rtc deprecated functions

On Tue, Jun 20, 2017 at 06:08:48PM +0200, Linus Walleij wrote:
> On Tue, Jun 20, 2017 at 11:35 AM, Benjamin Gaignard
> <[email protected]> wrote:
>
> > rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they
> > rely on 32bits variables and that will make rtc break in y2038/2016.
> > Stop using those two functions to safer 64bits ones.
> >
> > Signed-off-by: Benjamin Gaignard <[email protected]>
> > CC: Linus Walleij <[email protected]>
> > CC: Alessandro Zummo <[email protected]>
> > CC: Alexandre Belloni <[email protected]>
> > CC: [email protected]
> > CC: [email protected]
> > CC: [email protected]
>
> Acked-by: Linus Walleij <[email protected]>

Naked-again-by: Russell King

Really, people need to stop re-posting the same patches that have
already been naked.

This patch fixes NOTHING.

--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

2017-06-20 21:16:19

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On Tue, Jun 20, 2017 at 05:07:46PM +0200, Benjamin Gaignard wrote:
> 2017-06-20 15:48 GMT+02:00 Alexandre Belloni
> <[email protected]>:
> >> 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'd say that they should not be marked as deprecated. They're entirely
appropriate for use with hardware that only supports a 32-bit
representation of time.

It's entirely reasonable to fix the ones that use other representations
that exceed that, but for those which do not, we need to keep using the
32-bit versions. Doing so actually gives us _more_ flexibility in the
future.

Consider that at the moment, we define the 32-bit RTC representation to
start at a well known epoch. We _could_ decide that when it wraps to
0x80000000 seconds, we'll define the lower 0x40000000 seconds to mean
dates in the future - and keep rolling that forward each time we cross
another 0x40000000 seconds. Unless someone invents a real time machine,
we shouldn't need to set a modern RTC back to 1970.

If we convert the 32-bit counter RTC drivers to use 64-bit conversions,
then we're completely stuffed, because the lower 32-bits will always
be relative to the epoch, and we can't change that without breaking
the 64-bit users.

So, keep the 32-bit conversion functions, do not deprecate them, and
think about the future possibilities.

I really think this "get rid of 32-bit time representations" is a much
to narrow focus on the wrong problem. You can't ever fix 32-bit time
representations by just adding additional zeros into the MSB bits.

--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

2017-06-20 21:22:08

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 12/51] rtc: coh901331: stop using rtc deprecated functions

On Tue, Jun 20, 2017 at 11:35:20AM +0200, Benjamin Gaignard wrote:
> rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they
> rely on 32bits variables and that will make rtc break in y2038/2016.
> Stop using those two functions to safer 64bits ones.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Linus Walleij <[email protected]>
> CC: Alessandro Zummo <[email protected]>
> CC: Alexandre Belloni <[email protected]>
> CC: [email protected]
> CC: [email protected]
> CC: [email protected]
> ---
> 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)

Do you realise how stupid this is? Here, you're implicitly truncating
the 64-bit time value to 32-bit when you write it into the register.
So, when your clock wraps past 7 February 2106 (*not* 2038), when you
next read it, you read a date in 1970.

Exactly the same happens with the existing implementation, so this
fixes nothing at all. As I've said in my other mail, these changes
make it harder to fix the problem, because you're stuck with that
truncation - you can never do anything but truncate it.

Keeping the 32-bit conversion functions allows us to wind the date
progressively forward if we so choose.

Sure, if we don't want to maintain two conversion functions, then we
can define the 32-bit conversion functions in terms of the 64-bit
versions, but do _not_ get rid of them.

--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

2017-06-20 21:35:43

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On 20/06/2017 at 22:15:36 +0100, Russell King - ARM Linux wrote:
> On Tue, Jun 20, 2017 at 05:07:46PM +0200, Benjamin Gaignard wrote:
> > 2017-06-20 15:48 GMT+02:00 Alexandre Belloni
> > <[email protected]>:
> > >> 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'd say that they should not be marked as deprecated. They're entirely
> appropriate for use with hardware that only supports a 32-bit
> representation of time.
>
> It's entirely reasonable to fix the ones that use other representations
> that exceed that, but for those which do not, we need to keep using the
> 32-bit versions. Doing so actually gives us _more_ flexibility in the
> future.
>
> Consider that at the moment, we define the 32-bit RTC representation to
> start at a well known epoch. We _could_ decide that when it wraps to
> 0x80000000 seconds, we'll define the lower 0x40000000 seconds to mean
> dates in the future - and keep rolling that forward each time we cross
> another 0x40000000 seconds. Unless someone invents a real time machine,
> we shouldn't need to set a modern RTC back to 1970.
>

I agree with that but not the android guys. They seem to mandate an RTC
that can store time from 01/01/1970. I don't know much more than that
because they never cared to explain why that was actually necessary
(apart from a laconic "this will result in a bad user experience")

I think tglx had a plan for offsetting the time at some point so 32-bit
platform can pass 2038 properly.
My opinion is that as long as userspace is not ready to handle those
dates, it doesn't really matter because it is quite unlikely that
anything will be able to continue running anyway.

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

2017-06-20 22:01:15

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On Tue, 20 Jun 2017, Alexandre Belloni wrote:
> On 20/06/2017 at 22:15:36 +0100, Russell King - ARM Linux wrote:
> > On Tue, Jun 20, 2017 at 05:07:46PM +0200, Benjamin Gaignard wrote:
> > > 2017-06-20 15:48 GMT+02:00 Alexandre Belloni
> > > <[email protected]>:
> > > >> 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'd say that they should not be marked as deprecated. They're entirely
> > appropriate for use with hardware that only supports a 32-bit
> > representation of time.
> >
> > It's entirely reasonable to fix the ones that use other representations
> > that exceed that, but for those which do not, we need to keep using the
> > 32-bit versions. Doing so actually gives us _more_ flexibility in the
> > future.
> >
> > Consider that at the moment, we define the 32-bit RTC representation to
> > start at a well known epoch. We _could_ decide that when it wraps to
> > 0x80000000 seconds, we'll define the lower 0x40000000 seconds to mean
> > dates in the future - and keep rolling that forward each time we cross
> > another 0x40000000 seconds. Unless someone invents a real time machine,
> > we shouldn't need to set a modern RTC back to 1970.
> >
>
> I agree with that but not the android guys. They seem to mandate an RTC
> that can store time from 01/01/1970. I don't know much more than that
> because they never cared to explain why that was actually necessary
> (apart from a laconic "this will result in a bad user experience")
>
> I think tglx had a plan for offsetting the time at some point so 32-bit
> platform can pass 2038 properly.

Yes, but there are still quite some issues to solve there:

1) How do you tell the system that it should apply the offset in the
first place, i.e at boot time before NTP or any other mechanism can
correct it?

2) Deal with creative vendors who have their own idea about the 'start
of the epoch'

3) Add the information of wraparound time to the rtc device which
needs to be filled in for each device. That way the rtc_***
accessor functions can deal with them whether they wrap in 2038 or
2100 or whatever.

#3 is the simplest problem of them :)

> My opinion is that as long as userspace is not ready to handle those
> dates, it doesn't really matter because it is quite unlikely that
> anything will be able to continue running anyway.

That's a different story. Making the kernel y2038 ready in general is a
good thing. Whether userspace will be ready by then or not is completely
irrelevant.

Thanks,

tglx


2017-06-20 22:08:12

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

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.

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


Attachments:
(No filename) (1.24 kB)
signature.asc (181.00 B)
Digital signature
Download all attachments

2017-06-20 22:39:39

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On Wed, Jun 21, 2017 at 12:00:30AM +0200, Thomas Gleixner wrote:
> Yes, but there are still quite some issues to solve there:
>
> 1) How do you tell the system that it should apply the offset in the
> first place, i.e at boot time before NTP or any other mechanism can
> correct it?
>
> 2) Deal with creative vendors who have their own idea about the 'start
> of the epoch'
>
> 3) Add the information of wraparound time to the rtc device which
> needs to be filled in for each device. That way the rtc_***
> accessor functions can deal with them whether they wrap in 2038 or
> 2100 or whatever.
>
> #3 is the simplest problem of them :)

Well, if there's additional non-volatile storage, you can store
additional information in there, but you still need the RTC
subsystem to be aware that the hardware is only 32-bit capable.

You'd also still need something along the lines I detailed
(redefining what dates the past 32-bit values indicate) to cope
with the RTC being set backwards after the machine thinks (possibly
incorrectly) that the date has jumped forwards.

--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

2017-06-21 04:38:25

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 13/51] rtc: cpcap: stop using rtc deprecated functions

Hi Benjamin,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.12-rc6 next-20170620]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Benjamin-Gaignard/rtc-stop-using-rtc-deprecated-functions/20170621-044455
base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: arm-omap2plus_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All errors (new ones prefixed by >>):

>> ERROR: "__aeabi_uldivmod" [drivers/rtc/rtc-cpcap.ko] undefined!

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (1.01 kB)
.config.gz (29.03 kB)
Download all attachments

2017-06-21 04:46:25

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 32/51] rtc: pcap: stop using rtc deprecated functions

Hi Benjamin,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.12-rc6 next-20170620]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Benjamin-Gaignard/rtc-stop-using-rtc-deprecated-functions/20170621-044455
base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: i386-randconfig-b0-06210824 (attached as .config)
compiler: gcc-5 (Debian 5.4.1-2) 5.4.1 20160904
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All errors (new ones prefixed by >>):

drivers/built-in.o: In function `pcap_rtc_set_mmss64':
>> rtc-pcap.c:(.text+0x18a7e0): undefined reference to `__moddi3'
>> rtc-pcap.c:(.text+0x18a800): undefined reference to `__divdi3'
drivers/built-in.o: In function `pcap_rtc_set_alarm':
>> rtc-pcap.c:(.text+0x18a83e): undefined reference to `__umoddi3'
>> rtc-pcap.c:(.text+0x18a85e): undefined reference to `__udivdi3'

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (1.17 kB)
.config.gz (28.19 kB)
Download all attachments

2017-06-21 05:08:27

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 32/51] rtc: pcap: stop using rtc deprecated functions

Hi Benjamin,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.12-rc6 next-20170620]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Benjamin-Gaignard/rtc-stop-using-rtc-deprecated-functions/20170621-044455
base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: arm-ezx_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All errors (new ones prefixed by >>):

drivers/built-in.o: In function `pcap_rtc_set_mmss64':
>> hid-generic.c:(.text+0xac5b8): undefined reference to `__aeabi_ldivmod'
hid-generic.c:(.text+0xac5dc): undefined reference to `__aeabi_ldivmod'
drivers/built-in.o: In function `pcap_rtc_set_alarm':
>> hid-generic.c:(.text+0xac61c): undefined reference to `__aeabi_uldivmod'
hid-generic.c:(.text+0xac640): undefined reference to `__aeabi_uldivmod'

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (1.35 kB)
.config.gz (19.18 kB)
Download all attachments

2017-06-21 06:57:39

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 07/51] rtc: ab8500: stop using rtc deprecated functions

Hi Benjamin,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.12-rc6 next-20170620]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Benjamin-Gaignard/rtc-stop-using-rtc-deprecated-functions/20170621-044455
base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: arm-u8500_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All errors (new ones prefixed by >>):

drivers/built-in.o: In function `ab8540_rtc_set_alarm':
>> drivers/rtc/rtc-ab8500.c:299: undefined reference to `__aeabi_uldivmod'
drivers/rtc/rtc-ab8500.c:301: undefined reference to `__aeabi_uldivmod'
drivers/built-in.o: In function `ab8500_rtc_set_time':
drivers/rtc/rtc-ab8500.c:158: undefined reference to `__aeabi_uldivmod'
drivers/rtc/rtc-ab8500.c:160: undefined reference to `__aeabi_uldivmod'
drivers/built-in.o: In function `ab8500_rtc_set_alarm':
drivers/rtc/rtc-ab8500.c:263: undefined reference to `__aeabi_uldivmod'

vim +299 drivers/rtc/rtc-ab8500.c

45a9f91a Benjamin Gaignard 2017-06-20 293 secs = rtc_tm_to_time64(&alarm->time);
25d053cf Alexandre Torgue 2013-07-03 294
25d053cf Alexandre Torgue 2013-07-03 295 /*
25d053cf Alexandre Torgue 2013-07-03 296 * Convert it to the number of seconds since 01-01-2000 00:00:00
25d053cf Alexandre Torgue 2013-07-03 297 */
25d053cf Alexandre Torgue 2013-07-03 298 secs -= get_elapsed_seconds(AB8500_RTC_EPOCH);
25d053cf Alexandre Torgue 2013-07-03 @299 mins = secs / 60;
25d053cf Alexandre Torgue 2013-07-03 300
25d053cf Alexandre Torgue 2013-07-03 301 buf[3] = secs % 60;
25d053cf Alexandre Torgue 2013-07-03 302 buf[2] = mins & 0xFF;

:::::: The code at line 299 was first introduced by commit
:::::: 25d053cf1040e6430fff679854b3710edb0b7fee drivers/rtc/rtc-ab8500.c: add second resolution to rtc driver

:::::: TO: Alexandre Torgue <[email protected]>
:::::: CC: Linus Torvalds <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (2.45 kB)
.config.gz (21.88 kB)
Download all attachments

2017-06-21 07:52:03

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

Hi!

> > I agree with that but not the android guys. They seem to mandate an RTC
> > that can store time from 01/01/1970. I don't know much more than that
> > because they never cared to explain why that was actually necessary
> > (apart from a laconic "this will result in a bad user experience")
> >
> > I think tglx had a plan for offsetting the time at some point so 32-bit
> > platform can pass 2038 properly.
>
> Yes, but there are still quite some issues to solve there:
>
> 1) How do you tell the system that it should apply the offset in the
> first place, i.e at boot time before NTP or any other mechanism can
> correct it?

I'd not do offset. Instead, I'd select a threshold (perhaps year of
release of given kernel?) and

if (rtc_time < year_of_release_of_kernel)
rtc_time += 0x100000000;

Ok, we'll have to move away from "rtc_time == 0 indicates zero", as
seen in some drivers.

> 2) Deal with creative vendors who have their own idea about the 'start
> of the epoch'

If someone uses different threshold, well, there will be
confusion. But only for users that have their rtc set to the past,
which is quite unusual.

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


Attachments:
(No filename) (1.29 kB)
signature.asc (181.00 B)
Digital signature
Download all attachments

2017-06-21 08:39:29

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On 21/06/2017 at 09:51:52 +0200, Pavel Machek wrote:
> Hi!
>
> > > I agree with that but not the android guys. They seem to mandate an RTC
> > > that can store time from 01/01/1970. I don't know much more than that
> > > because they never cared to explain why that was actually necessary
> > > (apart from a laconic "this will result in a bad user experience")
> > >
> > > I think tglx had a plan for offsetting the time at some point so 32-bit
> > > platform can pass 2038 properly.
> >
> > Yes, but there are still quite some issues to solve there:
> >
> > 1) How do you tell the system that it should apply the offset in the
> > first place, i.e at boot time before NTP or any other mechanism can
> > correct it?
>
> I'd not do offset. Instead, I'd select a threshold (perhaps year of
> release of given kernel?) and
>
> if (rtc_time < year_of_release_of_kernel)
> rtc_time += 0x100000000;
>
> Ok, we'll have to move away from "rtc_time == 0 indicates zero", as
> seen in some drivers.
>
> > 2) Deal with creative vendors who have their own idea about the 'start
> > of the epoch'
>
> If someone uses different threshold, well, there will be
> confusion. But only for users that have their rtc set to the past,
> which is quite unusual.
>

Or not, having an RTC set in the past is actually quite common. I'd find
it weird to have a new device boot and be set to a date in the future.

Also note that the threshold or offset thing may seem like a good idea
but fails with many RTCs because of how they handle leap years.


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

2017-06-21 09:14:40

by Benjamin Gaignard

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

2017-06-21 0:08 GMT+02:00 Pavel Machek <[email protected]>:
> 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

2017-06-21 09:20:25

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On Wed, Jun 21, 2017 at 10:39:07AM +0200, Alexandre Belloni wrote:
> On 21/06/2017 at 09:51:52 +0200, Pavel Machek wrote:
> > If someone uses different threshold, well, there will be
> > confusion. But only for users that have their rtc set to the past,
> > which is quite unusual.
> >
>
> Or not, having an RTC set in the past is actually quite common. I'd find
> it weird to have a new device boot and be set to a date in the future.

... and that basically means you can't use hardware that stores RTC
time as a 32-bit number of seconds past 2106.

> Also note that the threshold or offset thing may seem like a good idea
> but fails with many RTCs because of how they handle leap years.

Not for the case being discussed. A 32-bit counter of seconds knows
nothing about leap years - all that is handled by the conversion
functions.

--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

2017-06-21 09:27:15

by David Laight

[permalink] [raw]
Subject: RE: [PATCH 00/51] rtc: stop using rtc deprecated functions

From: Russell King - ARM Linux
> Sent: 20 June 2017 22:16
..
> Consider that at the moment, we define the 32-bit RTC representation to
> start at a well known epoch. We _could_ decide that when it wraps to
> 0x80000000 seconds, we'll define the lower 0x40000000 seconds to mean
> dates in the future - and keep rolling that forward each time we cross
> another 0x40000000 seconds. Unless someone invents a real time machine,
> we shouldn't need to set a modern RTC back to 1970.

True, just treating the value as unsigned gives another 67 years.

If a 32bit RTC is programmed with the low 32bits of the 64bit 'seconds
since 1970' the kernel should have no real difficulty sorting out the
high bits from other available information.

Problems with things like the x86 bios setting the rtc to stupid values
are another matter.
ISTR the rtc chip has a bit for 'summertime' that is never set, on a
multi-os system you can get multiple summer time changes.

David

2017-06-21 09:36:14

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On Wed, Jun 21, 2017 at 09:26:51AM +0000, David Laight wrote:
> From: Russell King - ARM Linux
> > Sent: 20 June 2017 22:16
> ..
> > Consider that at the moment, we define the 32-bit RTC representation to
> > start at a well known epoch. We _could_ decide that when it wraps to
> > 0x80000000 seconds, we'll define the lower 0x40000000 seconds to mean
> > dates in the future - and keep rolling that forward each time we cross
> > another 0x40000000 seconds. Unless someone invents a real time machine,
> > we shouldn't need to set a modern RTC back to 1970.
>
> True, just treating the value as unsigned gives another 67 years.

We _already_ do treat it as an unsigned number, so already the panicing
about 2038 is complete and utter nonsense - that's why I've been
consistently stating the 2106 date.

> If a 32bit RTC is programmed with the low 32bits of the 64bit 'seconds
> since 1970' the kernel should have no real difficulty sorting out the
> high bits from other available information.

Right, but converting all the 32-bit conversion functions to 64-bit
means that rather than "sorting out" that from the core RTC driver,
we have to implement solutions in each and every driver.

While that may appear to be a good idea, many RTCs that are 32-bit
counters do not themselves have additional non-volatile storage, so
it means that we're ending up with a lot of RTC specific hacks to
go and get the additional information from some other driver elsewhere
in the system.

> Problems with things like the x86 bios setting the rtc to stupid values
> are another matter.

Forget x86, the RTC there does not store time as a 32-bit integer, it's
stored as its component values, and there's non-volatile memory attached
to the RTC. Hence, it's out of scope of "what to do about RTCs that
store time in 32-bit format" and also out of scope of "what to do about
RTC drivers that use the 32-bit time conversion function."

--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

2017-06-21 09:42:03

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On 21/06/2017 at 10:19:49 +0100, Russell King - ARM Linux wrote:
> On Wed, Jun 21, 2017 at 10:39:07AM +0200, Alexandre Belloni wrote:
> > On 21/06/2017 at 09:51:52 +0200, Pavel Machek wrote:
> > > If someone uses different threshold, well, there will be
> > > confusion. But only for users that have their rtc set to the past,
> > > which is quite unusual.
> > >
> >
> > Or not, having an RTC set in the past is actually quite common. I'd find
> > it weird to have a new device boot and be set to a date in the future.
>
> ... and that basically means you can't use hardware that stores RTC
> time as a 32-bit number of seconds past 2106.
>

And I guess it will not matter much for us anyway ;)

> > Also note that the threshold or offset thing may seem like a good idea
> > but fails with many RTCs because of how they handle leap years.
>
> Not for the case being discussed. A 32-bit counter of seconds knows
> nothing about leap years - all that is handled by the conversion
> functions.
>

Well, the patch series touches some RTCs that are not using 32 bit
counter so I though I might as well raise the issue now.

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

2017-06-21 11:36:12

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

Hi!

> > > > I think tglx had a plan for offsetting the time at some point so 32-bit
> > > > platform can pass 2038 properly.
> > >
> > > Yes, but there are still quite some issues to solve there:
> > >
> > > 1) How do you tell the system that it should apply the offset in the
> > > first place, i.e at boot time before NTP or any other mechanism can
> > > correct it?
> >
> > I'd not do offset. Instead, I'd select a threshold (perhaps year of
> > release of given kernel?) and
> >
> > if (rtc_time < year_of_release_of_kernel)
> > rtc_time += 0x100000000;
> >
> > Ok, we'll have to move away from "rtc_time == 0 indicates zero", as
> > seen in some drivers.
> >
> > > 2) Deal with creative vendors who have their own idea about the 'start
> > > of the epoch'
> >
> > If someone uses different threshold, well, there will be
> > confusion. But only for users that have their rtc set to the past,
> > which is quite unusual.
> >
>
> Or not, having an RTC set in the past is actually quite common. I'd find
> it weird to have a new device boot and be set to a date in the future.

...but still better than board stuck in the past, no?

> Also note that the threshold or offset thing may seem like a good idea
> but fails with many RTCs because of how they handle leap years.

Well, you can still convert time from rtc to unix time, then do adjustment
there.

Anyway, I guess it would be cool for rtc drivers to annotate what limits
underlying storage has to the common code, so that we can do fixups once
per class, not once per driver.
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2017-06-21 12:35:51

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

On 21/06/2017 at 08:34:43 +0200, Pavel Machek wrote:
> Hi!
>
> > > > > I think tglx had a plan for offsetting the time at some point so 32-bit
> > > > > platform can pass 2038 properly.
> > > >
> > > > Yes, but there are still quite some issues to solve there:
> > > >
> > > > 1) How do you tell the system that it should apply the offset in the
> > > > first place, i.e at boot time before NTP or any other mechanism can
> > > > correct it?
> > >
> > > I'd not do offset. Instead, I'd select a threshold (perhaps year of
> > > release of given kernel?) and
> > >
> > > if (rtc_time < year_of_release_of_kernel)
> > > rtc_time += 0x100000000;
> > >
> > > Ok, we'll have to move away from "rtc_time == 0 indicates zero", as
> > > seen in some drivers.
> > >
> > > > 2) Deal with creative vendors who have their own idea about the 'start
> > > > of the epoch'
> > >
> > > If someone uses different threshold, well, there will be
> > > confusion. But only for users that have their rtc set to the past,
> > > which is quite unusual.
> > >
> >
> > Or not, having an RTC set in the past is actually quite common. I'd find
> > it weird to have a new device boot and be set to a date in the future.
>
> ...but still better than board stuck in the past, no?
>
> > Also note that the threshold or offset thing may seem like a good idea
> > but fails with many RTCs because of how they handle leap years.
>
> Well, you can still convert time from rtc to unix time, then do adjustment
> there.
>

You can only if your machine is running when that happens. If that is
not the case, then you lost and your time is not correct anymore.

There is currently one rtc doing that kind of trick but it is used as a
simple time counter from the beginning. Transitioning is the difficult
part.

> Anyway, I guess it would be cool for rtc drivers to annotate what limits
> underlying storage has to the common code, so that we can do fixups once
> per class, not once per driver.

Yes, I'm in the middle of the whole rework that allows that.

I don't understand the sudden urgency of fixing that and the amount of
bikeshedding, seeing that the closest cutoff date is actually 31st of
december 2069 in the rtc subsystem and that anyway the current 32bit
userspace will explode in february 2038.

My plan from the beginning was to have something for the next stable. I
know nobody can read my mind but again, I don't think there is currently
any urgency to change anything.

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

2017-06-21 17:09:17

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 35/51] rtc: pm8xxx: stop using rtc deprecated functions

Hi Benjamin,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.12-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Benjamin-Gaignard/rtc-stop-using-rtc-deprecated-functions/20170621-044455
base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All errors (new ones prefixed by >>):

>> ERROR: "__udivdi3" [drivers/rtc/rtc-pcap.ko] undefined!
>> ERROR: "__umoddi3" [drivers/rtc/rtc-pcap.ko] undefined!
>> ERROR: "__divdi3" [drivers/rtc/rtc-pcap.ko] undefined!
>> ERROR: "__moddi3" [drivers/rtc/rtc-pcap.ko] undefined!
ERROR: "__umoddi3" [drivers/rtc/rtc-cpcap.ko] undefined!
ERROR: "__udivdi3" [drivers/rtc/rtc-cpcap.ko] undefined!

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (1.12 kB)
.config.gz (58.69 kB)
Download all attachments

2017-06-21 18:08:53

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 00/51] rtc: stop using rtc deprecated functions

Hi!

> > > Or not, having an RTC set in the past is actually quite common. I'd find
> > > it weird to have a new device boot and be set to a date in the future.
> >
> > ...but still better than board stuck in the past, no?
> >
> > > Also note that the threshold or offset thing may seem like a good idea
> > > but fails with many RTCs because of how they handle leap years.
> >
> > Well, you can still convert time from rtc to unix time, then do adjustment
> > there.
> >
>
> You can only if your machine is running when that happens. If that is
> not the case, then you lost and your time is not correct anymore.

I don't see why that should be a case... as long as you know what RTC
does in event of overflow, and it is not something completely crazy.

> > Anyway, I guess it would be cool for rtc drivers to annotate what limits
> > underlying storage has to the common code, so that we can do fixups once
> > per class, not once per driver.
>
> Yes, I'm in the middle of the whole rework that allows that.
>
> I don't understand the sudden urgency of fixing that and the amount of
> bikeshedding, seeing that the closest cutoff date is actually 31st of
> december 2069 in the rtc subsystem and that anyway the current 32bit
> userspace will explode in february 2038.
>
> My plan from the beginning was to have something for the next stable. I
> know nobody can read my mind but again, I don't think there is currently
> any urgency to change anything.

Yes, mind reading is a problem. I can only read minds of ferungulates,
and only if they are physicaly near me :-).

Best regards,
Pavel

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


Attachments:
(No filename) (1.71 kB)
signature.asc (181.00 B)
Digital signature
Download all attachments

2017-07-03 10:12:07

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 35/51] rtc: pm8xxx: stop using rtc deprecated functions

On Tue, Jun 20, 2017 at 11:35 AM, Benjamin Gaignard
<[email protected]> wrote:
> rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they
> rely on 32bits variables and that will make rtc break in y2038/2016.
> Stop using those two functions to safer 64bits ones.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> CC: Alessandro Zummo <[email protected]>
> CC: Alexandre Belloni <[email protected]>
> CC: [email protected]
> CC: [email protected]
> ---
> 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;

'secs' should be 'time64_t' here, which is signed.

> u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0;
> unsigned int ctrl_reg;
> struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
> @@ -90,14 +91,14 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
> if (!rtc_dd->allow_set_time)
> return -EACCES;
>
> - rtc_tm_to_time(tm, &secs);
> + secs = rtc_tm_to_time64(tm);
>
> for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) {
> value[i] = secs & 0xFF;
> secs >>= 8;
> }
>
> - dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs);
> + dev_dbg(dev, "Seconds value to be written to RTC = %llu\n", secs);
>

However, note that you only write 32 bits here, since NUM_8_BIT_RTC_REGS
is set to '4'. Is that a hardware constant? If yes, it would be best to return
-EINVAL or -EOVERFLOW for out of range times.

I think should really try to come up with a way to set the policy for
overflows in
RTC drivers globally in this case. There are many drivers that take a 32-bit
unsigned value (and many others that don't), but a nicer policy for the long
run might be to define some kind of windowing where values before e.g.
year 2000 or 2017 are wrapped around and used as future dates.

Unfortunately, the downside of this is that any RTC that defaults to '0'
and is now interpreted as year 1970 would then be interpreted as a future
data that can not be represented in today's 32-bit time_t.

Arnd