All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] drivers/rtc/pcf8563: Replace deprecated rtc_time_to_tm() and rtc_tm_to_time()
@ 2015-04-15  9:20 ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann, Xunlei Pang

From: Xunlei Pang <pang.xunlei@linaro.org>

pcf8563_rtc_set_alarm() uses deprecated rtc_tm_to_time()
and rtc_time_to_tm(), which will overflow in year 2106
on 32-bit machines.

This patch solves this by:
 - Replacing rtc_time_to_tm() with rtc_time64_to_tm()
 - Replacing rtc_tm_to_time() with rtc_tm_to_time64()

Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-pcf8563.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 96fb32e..4ce66ad 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -368,13 +368,13 @@ static int pcf8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *tm)
 	struct i2c_client *client = to_i2c_client(dev);
 	unsigned char buf[4];
 	int err;
-	unsigned long alarm_time;
 
 	/* The alarm has no seconds, round up to nearest minute */
 	if (tm->time.tm_sec) {
-		rtc_tm_to_time(&tm->time, &alarm_time);
-		alarm_time += 60-tm->time.tm_sec;
-		rtc_time_to_tm(alarm_time, &tm->time);
+		time64_t alarm_time = rtc_tm_to_time64(&tm->time);
+
+		alarm_time += 60 - tm->time.tm_sec;
+		rtc_time64_to_tm(alarm_time, &tm->time);
 	}
 
 	dev_dbg(dev, "%s, min=%d hour=%d wday=%d mday=%d "
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [1/5] drivers/rtc/pcf8563: Replace deprecated rtc_time_to_tm() and rtc_tm_to_time()
@ 2015-04-15  9:20 ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann, Xunlei Pang

From: Xunlei Pang <pang.xunlei@linaro.org>

pcf8563_rtc_set_alarm() uses deprecated rtc_tm_to_time()
and rtc_time_to_tm(), which will overflow in year 2106
on 32-bit machines.

This patch solves this by:
 - Replacing rtc_time_to_tm() with rtc_time64_to_tm()
 - Replacing rtc_tm_to_time() with rtc_tm_to_time64()

Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-pcf8563.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 96fb32e..4ce66ad 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -368,13 +368,13 @@ static int pcf8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *tm)
 	struct i2c_client *client = to_i2c_client(dev);
 	unsigned char buf[4];
 	int err;
-	unsigned long alarm_time;
 
 	/* The alarm has no seconds, round up to nearest minute */
 	if (tm->time.tm_sec) {
-		rtc_tm_to_time(&tm->time, &alarm_time);
-		alarm_time += 60-tm->time.tm_sec;
-		rtc_time_to_tm(alarm_time, &tm->time);
+		time64_t alarm_time = rtc_tm_to_time64(&tm->time);
+
+		alarm_time += 60 - tm->time.tm_sec;
+		rtc_time64_to_tm(alarm_time, &tm->time);
 	}
 
 	dev_dbg(dev, "%s, min=%d hour=%d wday=%d mday=%d "

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/5] drivers/rtc/isl1208: Replace deprecated rtc_tm_to_time()
@ 2015-04-15  9:20   ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann,
	Xunlei Pang, Herbert Valerio Riedel

From: Xunlei Pang <pang.xunlei@linaro.org>

isl1208_i2c_set_alarm() uses deprecated rtc_tm_to_time(),
which will overflow in year 2106 on 32-bit machines.

This patch solves this by:
 - Replacing rtc_tm_to_time() with rtc_tm_to_time64()

Cc: Herbert Valerio Riedel <hvr@gnu.org>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-isl1208.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index c3c549d..06113e8 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -370,19 +370,16 @@ isl1208_i2c_set_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm)
 	struct rtc_time *alarm_tm = &alarm->time;
 	u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, };
 	const int offs = ISL1208_REG_SCA;
-	unsigned long rtc_secs, alarm_secs;
+	time64_t rtc_secs, alarm_secs;
 	struct rtc_time rtc_tm;
 	int err, enable;
 
 	err = isl1208_i2c_read_time(client, &rtc_tm);
 	if (err)
 		return err;
-	err = rtc_tm_to_time(&rtc_tm, &rtc_secs);
-	if (err)
-		return err;
-	err = rtc_tm_to_time(alarm_tm, &alarm_secs);
-	if (err)
-		return err;
+
+	rtc_secs = rtc_tm_to_time64(&rtc_tm);
+	alarm_secs = rtc_tm_to_time64(alarm_tm);
 
 	/* If the alarm time is before the current time disable the alarm */
 	if (!alarm->enabled || alarm_secs <= rtc_secs)
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [2/5] drivers/rtc/isl1208: Replace deprecated rtc_tm_to_time()
@ 2015-04-15  9:20   ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann,
	Xunlei Pang, Herbert Valerio Riedel

From: Xunlei Pang <pang.xunlei@linaro.org>

isl1208_i2c_set_alarm() uses deprecated rtc_tm_to_time(),
which will overflow in year 2106 on 32-bit machines.

This patch solves this by:
 - Replacing rtc_tm_to_time() with rtc_tm_to_time64()

Cc: Herbert Valerio Riedel <hvr@gnu.org>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-isl1208.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index c3c549d..06113e8 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -370,19 +370,16 @@ isl1208_i2c_set_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm)
 	struct rtc_time *alarm_tm = &alarm->time;
 	u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, };
 	const int offs = ISL1208_REG_SCA;
-	unsigned long rtc_secs, alarm_secs;
+	time64_t rtc_secs, alarm_secs;
 	struct rtc_time rtc_tm;
 	int err, enable;
 
 	err = isl1208_i2c_read_time(client, &rtc_tm);
 	if (err)
 		return err;
-	err = rtc_tm_to_time(&rtc_tm, &rtc_secs);
-	if (err)
-		return err;
-	err = rtc_tm_to_time(alarm_tm, &alarm_secs);
-	if (err)
-		return err;
+
+	rtc_secs = rtc_tm_to_time64(&rtc_tm);
+	alarm_secs = rtc_tm_to_time64(alarm_tm);
 
 	/* If the alarm time is before the current time disable the alarm */
 	if (!alarm->enabled || alarm_secs <= rtc_secs)

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/5] drivers/rtc/sunxi: Replace deprecated rtc_tm_to_time()
@ 2015-04-15  9:20   ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann,
	Xunlei Pang, Carlo Caione

From: Xunlei Pang <pang.xunlei@linaro.org>

sunxi_rtc_setalarm() uses deprecated rtc_tm_to_time(),
which will overflow in year 2106 on 32-bit machines.

This patch solves this by:
- Replacing rtc_tm_to_time() with rtc_tm_to_time64()

Also remove the unnecessary initial zeroing of some
local variables in sunxi_rtc_setalarm().

Cc: Carlo Caione <carlo.caione@gmail.com>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-sunxi.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/rtc/rtc-sunxi.c b/drivers/rtc/rtc-sunxi.c
index 6e678fa..7f22753 100644
--- a/drivers/rtc/rtc-sunxi.c
+++ b/drivers/rtc/rtc-sunxi.c
@@ -269,14 +269,13 @@ static int sunxi_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
 	struct sunxi_rtc_dev *chip = dev_get_drvdata(dev);
 	struct rtc_time *alrm_tm = &wkalrm->time;
 	struct rtc_time tm_now;
-	u32 alrm = 0;
-	unsigned long time_now = 0;
-	unsigned long time_set = 0;
-	unsigned long time_gap = 0;
-	unsigned long time_gap_day = 0;
-	unsigned long time_gap_hour = 0;
-	unsigned long time_gap_min = 0;
-	int ret = 0;
+	u32 alrm;
+	time64_t time_set, time_now;
+	unsigned long time_gap;
+	unsigned long time_gap_day;
+	unsigned long time_gap_hour;
+	unsigned long time_gap_min;
+	int ret;
 
 	ret = sunxi_rtc_gettime(dev, &tm_now);
 	if (ret < 0) {
@@ -284,13 +283,18 @@ static int sunxi_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;
 	}
 
+	if (time_set > time_now + 255 * SEC_IN_DAY) {
+		dev_err(dev, "Day must be in the range 0 - 255\n");
+		return -EINVAL;
+	}
+
 	time_gap = time_set - time_now;
 	time_gap_day = time_gap / SEC_IN_DAY;
 	time_gap -= time_gap_day * SEC_IN_DAY;
@@ -299,11 +303,6 @@ static int sunxi_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
 	time_gap_min = time_gap / SEC_IN_MIN;
 	time_gap -= time_gap_min * SEC_IN_MIN;
 
-	if (time_gap_day > 255) {
-		dev_err(dev, "Day must be in the range 0 - 255\n");
-		return -EINVAL;
-	}
-
 	sunxi_rtc_setaie(0, chip);
 	writel(0, chip->base + SUNXI_ALRM_DHMS);
 	usleep_range(100, 300);
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [3/5] drivers/rtc/sunxi: Replace deprecated rtc_tm_to_time()
@ 2015-04-15  9:20   ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann,
	Xunlei Pang, Carlo Caione

From: Xunlei Pang <pang.xunlei@linaro.org>

sunxi_rtc_setalarm() uses deprecated rtc_tm_to_time(),
which will overflow in year 2106 on 32-bit machines.

This patch solves this by:
- Replacing rtc_tm_to_time() with rtc_tm_to_time64()

Also remove the unnecessary initial zeroing of some
local variables in sunxi_rtc_setalarm().

Cc: Carlo Caione <carlo.caione@gmail.com>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-sunxi.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/rtc/rtc-sunxi.c b/drivers/rtc/rtc-sunxi.c
index 6e678fa..7f22753 100644
--- a/drivers/rtc/rtc-sunxi.c
+++ b/drivers/rtc/rtc-sunxi.c
@@ -269,14 +269,13 @@ static int sunxi_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
 	struct sunxi_rtc_dev *chip = dev_get_drvdata(dev);
 	struct rtc_time *alrm_tm = &wkalrm->time;
 	struct rtc_time tm_now;
-	u32 alrm = 0;
-	unsigned long time_now = 0;
-	unsigned long time_set = 0;
-	unsigned long time_gap = 0;
-	unsigned long time_gap_day = 0;
-	unsigned long time_gap_hour = 0;
-	unsigned long time_gap_min = 0;
-	int ret = 0;
+	u32 alrm;
+	time64_t time_set, time_now;
+	unsigned long time_gap;
+	unsigned long time_gap_day;
+	unsigned long time_gap_hour;
+	unsigned long time_gap_min;
+	int ret;
 
 	ret = sunxi_rtc_gettime(dev, &tm_now);
 	if (ret < 0) {
@@ -284,13 +283,18 @@ static int sunxi_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;
 	}
 
+	if (time_set > time_now + 255 * SEC_IN_DAY) {
+		dev_err(dev, "Day must be in the range 0 - 255\n");
+		return -EINVAL;
+	}
+
 	time_gap = time_set - time_now;
 	time_gap_day = time_gap / SEC_IN_DAY;
 	time_gap -= time_gap_day * SEC_IN_DAY;
@@ -299,11 +303,6 @@ static int sunxi_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
 	time_gap_min = time_gap / SEC_IN_MIN;
 	time_gap -= time_gap_min * SEC_IN_MIN;
 
-	if (time_gap_day > 255) {
-		dev_err(dev, "Day must be in the range 0 - 255\n");
-		return -EINVAL;
-	}
-
 	sunxi_rtc_setaie(0, chip);
 	writel(0, chip->base + SUNXI_ALRM_DHMS);
 	usleep_range(100, 300);

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 4/5] drivers/rtc/pl030: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
@ 2015-04-15  9:20   ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann,
	Xunlei Pang, Russell King

From: Xunlei Pang <pang.xunlei@linaro.org>

The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(),
which will overflow in year 2106 on 32-bit machines.

This patch solves this by:
 - Replacing rtc_tm_to_time() with rtc_tm_to_time64()
 - Replacing rtc_time_to_tm() with rtc_time64_to_tm()

Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-pl030.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index f85a1a9..d874b6e 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -39,32 +39,34 @@ 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;
+	time64_t 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);
-	return ret;
+	if (ret)
+		return ret;
+
+	time = rtc_tm_to_time64(&alrm->time);
+	writel(time, rtc->base + RTC_MR);
+
+	return 0;
 }
 
 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;
 }
@@ -80,14 +82,12 @@ static int pl030_read_time(struct device *dev, struct rtc_time *tm)
 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;
+	time64_t time;
 
-	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



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [4/5] drivers/rtc/pl030: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
@ 2015-04-15  9:20   ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann,
	Xunlei Pang, Russell King

From: Xunlei Pang <pang.xunlei@linaro.org>

The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(),
which will overflow in year 2106 on 32-bit machines.

This patch solves this by:
 - Replacing rtc_tm_to_time() with rtc_tm_to_time64()
 - Replacing rtc_time_to_tm() with rtc_time64_to_tm()

Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-pl030.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index f85a1a9..d874b6e 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -39,32 +39,34 @@ 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;
+	time64_t 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);
-	return ret;
+	if (ret)
+		return ret;
+
+	time = rtc_tm_to_time64(&alrm->time);
+	writel(time, rtc->base + RTC_MR);
+
+	return 0;
 }
 
 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;
 }
@@ -80,14 +82,12 @@ static int pl030_read_time(struct device *dev, struct rtc_time *tm)
 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;
+	time64_t time;
 
-	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 = {

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
@ 2015-04-15  9:20   ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann,
	Xunlei Pang, CIH, Nicolas Pitre, Andrew Christian,
	Richard Purdie

From: Xunlei Pang <pang.xunlei@linaro.org>

The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(),
which will overflow in year 2106 on 32-bit machines.

This patch solves this by:
 - Replacing rtc_tm_to_time() with rtc_tm_to_time64()
 - Replacing rtc_time_to_tm() with rtc_time64_to_tm()

Cc: CIH <cih@coventive.com>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Andrew Christian <andrew.christian@hp.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-sa1100.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index b6e1ca0..625a320 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -157,19 +157,14 @@ static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
 
 static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
-	rtc_time_to_tm(RCNR, tm);
+	rtc_time64_to_tm(RCNR, tm);
 	return 0;
 }
 
 static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
-	unsigned long time;
-	int ret;
-
-	ret = rtc_tm_to_time(tm, &time);
-	if (ret == 0)
-		RCNR = time;
-	return ret;
+	RCNR = rtc_tm_to_time64(tm);
+	return 0;
 }
 
 static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
@@ -185,23 +180,17 @@ 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;
 
 	spin_lock_irq(&info->lock);
-	ret = rtc_tm_to_time(&alrm->time, &time);
-	if (ret != 0)
-		goto out;
 	RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
-	RTAR = time;
+	RTAR = rtc_tm_to_time64(&alrm->time);
 	if (alrm->enabled)
 		RTSR |= RTSR_ALE;
 	else
 		RTSR &= ~RTSR_ALE;
-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



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
@ 2015-04-15  9:20   ` Xunlei Pang
  0 siblings, 0 replies; 21+ messages in thread
From: Xunlei Pang @ 2015-04-15  9:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, John Stultz, Arnd Bergmann,
	Xunlei Pang, CIH, Nicolas Pitre, Andrew Christian,
	Richard Purdie

From: Xunlei Pang <pang.xunlei@linaro.org>

The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(),
which will overflow in year 2106 on 32-bit machines.

This patch solves this by:
 - Replacing rtc_tm_to_time() with rtc_tm_to_time64()
 - Replacing rtc_time_to_tm() with rtc_time64_to_tm()

Cc: CIH <cih@coventive.com>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Andrew Christian <andrew.christian@hp.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/rtc-sa1100.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index b6e1ca0..625a320 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -157,19 +157,14 @@ static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
 
 static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
-	rtc_time_to_tm(RCNR, tm);
+	rtc_time64_to_tm(RCNR, tm);
 	return 0;
 }
 
 static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
-	unsigned long time;
-	int ret;
-
-	ret = rtc_tm_to_time(tm, &time);
-	if (ret == 0)
-		RCNR = time;
-	return ret;
+	RCNR = rtc_tm_to_time64(tm);
+	return 0;
 }
 
 static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
@@ -185,23 +180,17 @@ 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;
 
 	spin_lock_irq(&info->lock);
-	ret = rtc_tm_to_time(&alrm->time, &time);
-	if (ret != 0)
-		goto out;
 	RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
-	RTAR = time;
+	RTAR = rtc_tm_to_time64(&alrm->time);
 	if (alrm->enabled)
 		RTSR |= RTSR_ALE;
 	else
 		RTSR &= ~RTSR_ALE;
-out:
 	spin_unlock_irq(&info->lock);
 
-	return ret;
+	return 0;
 }
 
 static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/5] drivers/rtc/pl030: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
  2015-04-15  9:20   ` [4/5] " Xunlei Pang
@ 2015-04-15  9:35     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 21+ messages in thread
From: Russell King - ARM Linux @ 2015-04-15  9:35 UTC (permalink / raw)
  To: Xunlei Pang
  Cc: linux-kernel, rtc-linux, Alessandro Zummo, John Stultz,
	Arnd Bergmann, Xunlei Pang

On Wed, Apr 15, 2015 at 05:20:10PM +0800, Xunlei Pang wrote:
> From: Xunlei Pang <pang.xunlei@linaro.org>
> 
> The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(),
> which will overflow in year 2106 on 32-bit machines.
> 
> This patch solves this by:
>  - Replacing rtc_tm_to_time() with rtc_tm_to_time64()
>  - Replacing rtc_time_to_tm() with rtc_time64_to_tm()
> 
> Cc: Russell King <rmk+kernel@arm.linux.org.uk>
> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>

NAK.

How does this fix anything?  The RTC contains 32-bit registers.  Even
if you convert the struct tm to a 64-bit time, you can only write the
lowest 32-bits to the hardware.  You can onyl read the lowest 32-bits
from the hardware too.

This patch solves /nothing/.  In fact, it hides the fact that this RTC
is unable to represent dates after 2106.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [rtc-linux] Re: [PATCH 4/5] drivers/rtc/pl030: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
@ 2015-04-15  9:35     ` Russell King - ARM Linux
  0 siblings, 0 replies; 21+ messages in thread
From: Russell King - ARM Linux @ 2015-04-15  9:35 UTC (permalink / raw)
  To: Xunlei Pang
  Cc: linux-kernel, rtc-linux, Alessandro Zummo, John Stultz,
	Arnd Bergmann, Xunlei Pang

On Wed, Apr 15, 2015 at 05:20:10PM +0800, Xunlei Pang wrote:
> From: Xunlei Pang <pang.xunlei@linaro.org>
> 
> The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(),
> which will overflow in year 2106 on 32-bit machines.
> 
> This patch solves this by:
>  - Replacing rtc_tm_to_time() with rtc_tm_to_time64()
>  - Replacing rtc_time_to_tm() with rtc_time64_to_tm()
> 
> Cc: Russell King <rmk+kernel@arm.linux.org.uk>
> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>

NAK.

How does this fix anything?  The RTC contains 32-bit registers.  Even
if you convert the struct tm to a 64-bit time, you can only write the
lowest 32-bits to the hardware.  You can onyl read the lowest 32-bits
from the hardware too.

This patch solves /nothing/.  In fact, it hides the fact that this RTC
is unable to represent dates after 2106.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
  2015-04-15  9:20   ` [5/5] " Xunlei Pang
  (?)
@ 2015-04-29 23:28   ` Alexandre Belloni
  2015-05-29 14:32     ` [rtc-linux] " pang.xunlei
       [not found]     ` <OF1F6D43BC.C38481A0-ON48257E54.004FA90B-48257E54.004FD9D8@LocalDomain>
  -1 siblings, 2 replies; 21+ messages in thread
From: Alexandre Belloni @ 2015-04-29 23:28 UTC (permalink / raw)
  To: Xunlei Pang
  Cc: linux-kernel, rtc-linux, Alessandro Zummo, John Stultz,
	Arnd Bergmann, Xunlei Pang, CIH, Nicolas Pitre, Andrew Christian,
	Richard Purdie

Hi,

On 15/04/2015 at 17:20:11 +0800, Xunlei Pang wrote :
> From: Xunlei Pang <pang.xunlei@linaro.org>
> 
> The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(),
> which will overflow in year 2106 on 32-bit machines.
> 
> This patch solves this by:
>  - Replacing rtc_tm_to_time() with rtc_tm_to_time64()
>  - Replacing rtc_time_to_tm() with rtc_time64_to_tm()
> 
> Cc: CIH <cih@coventive.com>
> Cc: Nicolas Pitre <nico@fluxnic.net>
> Cc: Andrew Christian <andrew.christian@hp.com>
> Cc: Richard Purdie <rpurdie@rpsys.net>
> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
> ---
>  drivers/rtc/rtc-sa1100.c | 21 +++++----------------
>  1 file changed, 5 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
> index b6e1ca0..625a320 100644
> --- a/drivers/rtc/rtc-sa1100.c
> +++ b/drivers/rtc/rtc-sa1100.c
> @@ -157,19 +157,14 @@ static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
>  
>  static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
>  {
> -	rtc_time_to_tm(RCNR, tm);
> +	rtc_time64_to_tm(RCNR, tm);
>  	return 0;
>  }
>  
>  static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
>  {
> -	unsigned long time;
> -	int ret;
> -
> -	ret = rtc_tm_to_time(tm, &time);
> -	if (ret == 0)
> -		RCNR = time;
> -	return ret;
> +	RCNR = rtc_tm_to_time64(tm);

For the same reason that Russell pointed in patch 4/5, this hides that
it doesn't work after 2106-02-07 06:28:16 as the register is still 32
bits.
I would prefer that you return an error in that case.


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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [rtc-linux] Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
  2015-04-29 23:28   ` Alexandre Belloni
@ 2015-05-29 14:32     ` pang.xunlei
       [not found]     ` <OF1F6D43BC.C38481A0-ON48257E54.004FA90B-48257E54.004FD9D8@LocalDomain>
  1 sibling, 0 replies; 21+ messages in thread
From: pang.xunlei @ 2015-05-29 14:32 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Alessandro Zummo, Andrew Christian, Arnd Bergmann, CIH,
	John Stultz, linux-kernel, Nicolas Pitre, Xunlei Pang,
	Richard Purdie, rtc-linux, Xunlei Pang

[-- Attachment #1: Type: text/plain, Size: 3758 bytes --]

Hi Alexandre,

Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote 2015-04-30 
AM 07:28:24:
> 
> Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() 
> and rtc_time_to_tm()
> 
> Hi,
> 
> On 15/04/2015 at 17:20:11 +0800, Xunlei Pang wrote :
> > From: Xunlei Pang <pang.xunlei@linaro.org>
> > 
> > The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(),
> > which will overflow in year 2106 on 32-bit machines.
> > 
> > This patch solves this by:
> >  - Replacing rtc_tm_to_time() with rtc_tm_to_time64()
> >  - Replacing rtc_time_to_tm() with rtc_time64_to_tm()
> > 
> > Cc: CIH <cih@coventive.com>
> > Cc: Nicolas Pitre <nico@fluxnic.net>
> > Cc: Andrew Christian <andrew.christian@hp.com>
> > Cc: Richard Purdie <rpurdie@rpsys.net>
> > Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
> > ---
> >  drivers/rtc/rtc-sa1100.c | 21 +++++----------------
> >  1 file changed, 5 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
> > index b6e1ca0..625a320 100644
> > --- a/drivers/rtc/rtc-sa1100.c
> > +++ b/drivers/rtc/rtc-sa1100.c
> > @@ -157,19 +157,14 @@ static int sa1100_rtc_alarm_irq_enable
> (struct device *dev, unsigned int enabled)
> > 
> >  static int sa1100_rtc_read_time(struct device *dev, struct rtc_time 
*tm)
> >  {
> > -   rtc_time_to_tm(RCNR, tm);
> > +   rtc_time64_to_tm(RCNR, tm);
> >     return 0;
> >  }
> > 
> >  static int sa1100_rtc_set_time(struct device *dev, struct rtc_time 
*tm)
> >  {
> > -   unsigned long time;
> > -   int ret;
> > -
> > -   ret = rtc_tm_to_time(tm, &time);
> > -   if (ret == 0)
> > -      RCNR = time;
> > -   return ret;
> > +   RCNR = rtc_tm_to_time64(tm);
> 
> For the same reason that Russell pointed in patch 4/5, this hides that
> it doesn't work after 2106-02-07 06:28:16 as the register is still 32
> bits.
> I would prefer that you return an error in that case.

Thanks for the review, I want to leave the ones like this untouched.

Regards,
-Xunlei

> 
> 
> -- 
> Alexandre Belloni, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.
--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.

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

[-- Attachment #2: Type: text/html, Size: 5240 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [rtc-linux] Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
       [not found]     ` <OF1F6D43BC.C38481A0-ON48257E54.004FA90B-48257E54.004FD9D8@LocalDomain>
@ 2015-05-30 10:05       ` pang.xunlei
  2015-06-01 19:43           ` [rtc-linux] " Arnd Bergmann
  0 siblings, 1 reply; 21+ messages in thread
From: pang.xunlei @ 2015-05-30 10:05 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Alessandro Zummo, Andrew Christian, Arnd Bergmann, CIH,
	John Stultz, linux-kernel, Nicolas Pitre, Xunlei Pang,
	Richard Purdie, rtc-linux, Xunlei Pang

[-- Attachment #1: Type: text/plain, Size: 4304 bytes --]

PangXunLei10110855/user/zte_ltd wrote 2015-05-29 PM 10:32:15:
> Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() 
> and rtc_time_to_tm()
> 
> Hi Alexandre,
> 
> Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote 
> 2015-04-30 AM 07:28:24:
> > 
> > Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() 
> > and rtc_time_to_tm()
> > 
> > Hi,
> > 
> > On 15/04/2015 at 17:20:11 +0800, Xunlei Pang wrote :
> > > From: Xunlei Pang <pang.xunlei@linaro.org>
> > > 
> > > The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(),
> > > which will overflow in year 2106 on 32-bit machines.
> > > 
> > > This patch solves this by:
> > >  - Replacing rtc_tm_to_time() with rtc_tm_to_time64()
> > >  - Replacing rtc_time_to_tm() with rtc_time64_to_tm()
> > > 
> > > Cc: CIH <cih@coventive.com>
> > > Cc: Nicolas Pitre <nico@fluxnic.net>
> > > Cc: Andrew Christian <andrew.christian@hp.com>
> > > Cc: Richard Purdie <rpurdie@rpsys.net>
> > > Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
> > > ---
> > >  drivers/rtc/rtc-sa1100.c | 21 +++++----------------
> > >  1 file changed, 5 insertions(+), 16 deletions(-)
> > > 
> > > diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
> > > index b6e1ca0..625a320 100644
> > > --- a/drivers/rtc/rtc-sa1100.c
> > > +++ b/drivers/rtc/rtc-sa1100.c
> > > @@ -157,19 +157,14 @@ static int sa1100_rtc_alarm_irq_enable
> > (struct device *dev, unsigned int enabled)
> > > 
> > >  static int sa1100_rtc_read_time(struct device *dev, struct rtc_time 
*tm)
> > >  {
> > > -   rtc_time_to_tm(RCNR, tm);
> > > +   rtc_time64_to_tm(RCNR, tm);
> > >     return 0;
> > >  }
> > > 
> > >  static int sa1100_rtc_set_time(struct device *dev, struct rtc_time 
*tm)
> > >  {
> > > -   unsigned long time;
> > > -   int ret;
> > > -
> > > -   ret = rtc_tm_to_time(tm, &time);
> > > -   if (ret == 0)
> > > -      RCNR = time;
> > > -   return ret;
> > > +   RCNR = rtc_tm_to_time64(tm);
> > 
> > For the same reason that Russell pointed in patch 4/5, this hides that
> > it doesn't work after 2106-02-07 06:28:16 as the register is still 32
> > bits.
> > I would prefer that you return an error in that case.
> 
> Thanks for the review, I want to leave the ones like this untouched.
> 

To further explain, for the rtc hardware with 32-bit counters, we actually 

had a solution before: https://lkml.org/lkml/2014/11/27/341

But seems some guys don't like the solution, so rtc drivers like this one 
can't be simply changed to use the new-added y2038-safe interfaces.

Maybe those drivers will still retain the deprecated interfaces until a 
better solution is proposed.

Thanks,
-Xunlei
--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.
--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.

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

[-- Attachment #2: Type: text/html, Size: 6178 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
  2015-05-30 10:05       ` pang.xunlei
@ 2015-06-01 19:43           ` Arnd Bergmann
  0 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2015-06-01 19:43 UTC (permalink / raw)
  To: pang.xunlei
  Cc: Alexandre Belloni, Alessandro Zummo, Andrew Christian, CIH,
	John Stultz, linux-kernel, Nicolas Pitre, Xunlei Pang,
	Richard Purdie, rtc-linux, Xunlei Pang

On Saturday 30 May 2015 18:05:10 pang.xunlei@zte.com.cn wrote:
> PangXunLei10110855/user/zte_ltd wrote 2015-05-29 PM 10:32:15:
> > Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote 
> > 2015-04-30 AM 07:28:24:
> > > Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() 
> > > and rtc_time_to_tm()
> > > 
> > > For the same reason that Russell pointed in patch 4/5, this hides that
> > > it doesn't work after 2106-02-07 06:28:16 as the register is still 32
> > > bits.
> > > I would prefer that you return an error in that case.
> > 
> > Thanks for the review, I want to leave the ones like this untouched.
> > 
> 
> To further explain, for the rtc hardware with 32-bit counters, we actually 
> 
> had a solution before: https://lkml.org/lkml/2014/11/27/341
> 
> But seems some guys don't like the solution, so rtc drivers like this one 
> can't be simply changed to use the new-added y2038-safe interfaces.
> 
> Maybe those drivers will still retain the deprecated interfaces until a 
> better solution is proposed.

Note that Alexandre has stepped up as a new maintainer for RTC now,
so whatever he wants is probably the way it should be done.

I think the way that your first approach came out was a bit unfortunate,
because we didn't have agreement on how it should really be done.

IMHO the rtc_time64_to_hw32 and rtc_hw32_to_time64 interfaces were a
good concept, most importantly so we can easily find where the potential
problems are, but the implementation was a bit too ambitious in trying
to fix the underlying issue.

If we want to start this over again, I think a better approach would be
to introduce trivial functions at first, like

time64_t rtc_hw32_to_time64(u32 hwtime)
{
	/* 
	 * this is safe until about 2106, when unsigned u32 seconds from the
	 * 1970 epoch will overflow
	 */
	return (u64)hwtime;
}
EXPORT_SYMBOL_GPL(rtc_hw32_to_time64);

This way, we can fix all the drivers without introducing any possible
ambiguity and later decide how that function should in fact handle the
2106 overflow. Our grandchildren can take care of that if necessary ;-)

	Arnd

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [rtc-linux] Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
@ 2015-06-01 19:43           ` Arnd Bergmann
  0 siblings, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2015-06-01 19:43 UTC (permalink / raw)
  To: pang.xunlei
  Cc: Alexandre Belloni, Alessandro Zummo, Andrew Christian, CIH,
	John Stultz, linux-kernel, Nicolas Pitre, Xunlei Pang,
	Richard Purdie, rtc-linux, Xunlei Pang

On Saturday 30 May 2015 18:05:10 pang.xunlei@zte.com.cn wrote:
> PangXunLei10110855/user/zte_ltd wrote 2015-05-29 PM 10:32:15:
> > Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote 
> > 2015-04-30 AM 07:28:24:
> > > Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() 
> > > and rtc_time_to_tm()
> > > 
> > > For the same reason that Russell pointed in patch 4/5, this hides that
> > > it doesn't work after 2106-02-07 06:28:16 as the register is still 32
> > > bits.
> > > I would prefer that you return an error in that case.
> > 
> > Thanks for the review, I want to leave the ones like this untouched.
> > 
> 
> To further explain, for the rtc hardware with 32-bit counters, we actually 
> 
> had a solution before: https://lkml.org/lkml/2014/11/27/341
> 
> But seems some guys don't like the solution, so rtc drivers like this one 
> can't be simply changed to use the new-added y2038-safe interfaces.
> 
> Maybe those drivers will still retain the deprecated interfaces until a 
> better solution is proposed.

Note that Alexandre has stepped up as a new maintainer for RTC now,
so whatever he wants is probably the way it should be done.

I think the way that your first approach came out was a bit unfortunate,
because we didn't have agreement on how it should really be done.

IMHO the rtc_time64_to_hw32 and rtc_hw32_to_time64 interfaces were a
good concept, most importantly so we can easily find where the potential
problems are, but the implementation was a bit too ambitious in trying
to fix the underlying issue.

If we want to start this over again, I think a better approach would be
to introduce trivial functions at first, like

time64_t rtc_hw32_to_time64(u32 hwtime)
{
	/* 
	 * this is safe until about 2106, when unsigned u32 seconds from the
	 * 1970 epoch will overflow
	 */
	return (u64)hwtime;
}
EXPORT_SYMBOL_GPL(rtc_hw32_to_time64);

This way, we can fix all the drivers without introducing any possible
ambiguity and later decide how that function should in fact handle the
2106 overflow. Our grandchildren can take care of that if necessary ;-)

	Arnd

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
  2015-06-01 19:43           ` [rtc-linux] " Arnd Bergmann
@ 2015-06-01 19:59             ` Alexandre Belloni
  -1 siblings, 0 replies; 21+ messages in thread
From: Alexandre Belloni @ 2015-06-01 19:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: pang.xunlei, Alessandro Zummo, Andrew Christian, CIH,
	John Stultz, linux-kernel, Nicolas Pitre, Xunlei Pang,
	Richard Purdie, rtc-linux, Xunlei Pang

Hi,

On 01/06/2015 at 21:43:22 +0200, Arnd Bergmann wrote :
> Note that Alexandre has stepped up as a new maintainer for RTC now,
> so whatever he wants is probably the way it should be done.
> 

I'm still quite new in that position and I didn't make my mind in a lot
of different topics ;)

> I think the way that your first approach came out was a bit unfortunate,
> because we didn't have agreement on how it should really be done.
> 
> IMHO the rtc_time64_to_hw32 and rtc_hw32_to_time64 interfaces were a
> good concept, most importantly so we can easily find where the potential
> problems are, but the implementation was a bit too ambitious in trying
> to fix the underlying issue.
> 
> If we want to start this over again, I think a better approach would be
> to introduce trivial functions at first, like
> 
> time64_t rtc_hw32_to_time64(u32 hwtime)
> {
> 	/* 
> 	 * this is safe until about 2106, when unsigned u32 seconds from the
> 	 * 1970 epoch will overflow
> 	 */
> 	return (u64)hwtime;
> }
> EXPORT_SYMBOL_GPL(rtc_hw32_to_time64);
> 
> This way, we can fix all the drivers without introducing any possible
> ambiguity and later decide how that function should in fact handle the
> 2106 overflow. Our grandchildren can take care of that if necessary ;-)
> 

We also have RTCs that can only store the year as an integer between 0
and 99. Some of them will definitively not pass 2099, considering that
the can only handle leap days between 2000 and 2099. Also, we have a few
drivers assuming that year >= 70 is in the 19s so they will stop working
correctly in 2070. I think we also have to consider those while trying
to find a solution.

I feel that we still have a bit of time before having to hurry and find
a proper solution ;)

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [rtc-linux] Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
@ 2015-06-01 19:59             ` Alexandre Belloni
  0 siblings, 0 replies; 21+ messages in thread
From: Alexandre Belloni @ 2015-06-01 19:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: pang.xunlei, Alessandro Zummo, Andrew Christian, CIH,
	John Stultz, linux-kernel, Nicolas Pitre, Xunlei Pang,
	Richard Purdie, rtc-linux, Xunlei Pang

Hi,

On 01/06/2015 at 21:43:22 +0200, Arnd Bergmann wrote :
> Note that Alexandre has stepped up as a new maintainer for RTC now,
> so whatever he wants is probably the way it should be done.
> 

I'm still quite new in that position and I didn't make my mind in a lot
of different topics ;)

> I think the way that your first approach came out was a bit unfortunate,
> because we didn't have agreement on how it should really be done.
> 
> IMHO the rtc_time64_to_hw32 and rtc_hw32_to_time64 interfaces were a
> good concept, most importantly so we can easily find where the potential
> problems are, but the implementation was a bit too ambitious in trying
> to fix the underlying issue.
> 
> If we want to start this over again, I think a better approach would be
> to introduce trivial functions at first, like
> 
> time64_t rtc_hw32_to_time64(u32 hwtime)
> {
> 	/* 
> 	 * this is safe until about 2106, when unsigned u32 seconds from the
> 	 * 1970 epoch will overflow
> 	 */
> 	return (u64)hwtime;
> }
> EXPORT_SYMBOL_GPL(rtc_hw32_to_time64);
> 
> This way, we can fix all the drivers without introducing any possible
> ambiguity and later decide how that function should in fact handle the
> 2106 overflow. Our grandchildren can take care of that if necessary ;-)
> 

We also have RTCs that can only store the year as an integer between 0
and 99. Some of them will definitively not pass 2099, considering that
the can only handle leap days between 2000 and 2099. Also, we have a few
drivers assuming that year >= 70 is in the 19s so they will stop working
correctly in 2070. I think we also have to consider those while trying
to find a solution.

I feel that we still have a bit of time before having to hurry and find
a proper solution ;)

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

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
  2015-06-01 19:59             ` [rtc-linux] " Alexandre Belloni
@ 2015-06-03 14:17               ` Alessandro Zummo
  -1 siblings, 0 replies; 21+ messages in thread
From: Alessandro Zummo @ 2015-06-03 14:17 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Arnd Bergmann, pang.xunlei, Andrew Christian, CIH, John Stultz,
	linux-kernel, Nicolas Pitre, Xunlei Pang, Richard Purdie,
	rtc-linux, Xunlei Pang

On Mon, 1 Jun 2015 21:59:09 +0200
Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:

> I feel that we still have a bit of time before having to hurry and find
> a proper solution ;)

 agreed :)

-- 

 Best regards,

 Alessandro Zummo - CEO,
  Tower Technologies - Torino, Italy

  http://www.towertech.it


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [rtc-linux] Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
@ 2015-06-03 14:17               ` Alessandro Zummo
  0 siblings, 0 replies; 21+ messages in thread
From: Alessandro Zummo @ 2015-06-03 14:17 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Arnd Bergmann, pang.xunlei, Andrew Christian, CIH, John Stultz,
	linux-kernel, Nicolas Pitre, Xunlei Pang, Richard Purdie,
	rtc-linux, Xunlei Pang

On Mon, 1 Jun 2015 21:59:09 +0200
Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:

> I feel that we still have a bit of time before having to hurry and find
> a proper solution ;)

 agreed :)

-- 

 Best regards,

 Alessandro Zummo - CEO,
  Tower Technologies - Torino, Italy

  http://www.towertech.it

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2015-06-03 14:24 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-15  9:20 [PATCH 1/5] drivers/rtc/pcf8563: Replace deprecated rtc_time_to_tm() and rtc_tm_to_time() Xunlei Pang
2015-04-15  9:20 ` [1/5] " Xunlei Pang
2015-04-15  9:20 ` [PATCH 2/5] drivers/rtc/isl1208: Replace deprecated rtc_tm_to_time() Xunlei Pang
2015-04-15  9:20   ` [2/5] " Xunlei Pang
2015-04-15  9:20 ` [PATCH 3/5] drivers/rtc/sunxi: " Xunlei Pang
2015-04-15  9:20   ` [3/5] " Xunlei Pang
2015-04-15  9:20 ` [PATCH 4/5] drivers/rtc/pl030: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm() Xunlei Pang
2015-04-15  9:20   ` [4/5] " Xunlei Pang
2015-04-15  9:35   ` [PATCH 4/5] " Russell King - ARM Linux
2015-04-15  9:35     ` [rtc-linux] " Russell King - ARM Linux
2015-04-15  9:20 ` [PATCH 5/5] drivers/rtc/sa1100: " Xunlei Pang
2015-04-15  9:20   ` [5/5] " Xunlei Pang
2015-04-29 23:28   ` Alexandre Belloni
2015-05-29 14:32     ` [rtc-linux] " pang.xunlei
     [not found]     ` <OF1F6D43BC.C38481A0-ON48257E54.004FA90B-48257E54.004FD9D8@LocalDomain>
2015-05-30 10:05       ` pang.xunlei
2015-06-01 19:43         ` Arnd Bergmann
2015-06-01 19:43           ` [rtc-linux] " Arnd Bergmann
2015-06-01 19:59           ` Alexandre Belloni
2015-06-01 19:59             ` [rtc-linux] " Alexandre Belloni
2015-06-03 14:17             ` Alessandro Zummo
2015-06-03 14:17               ` [rtc-linux] " Alessandro Zummo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.