linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] rtc: tx4939: remove useless test
@ 2019-03-03 22:21 Alexandre Belloni
  2019-03-03 22:21 ` [PATCH 2/4] rtc: tx4939: set range Alexandre Belloni
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexandre Belloni @ 2019-03-03 22:21 UTC (permalink / raw)
  To: linux-rtc; +Cc: Alexandre Belloni

The tested condition will never happen as the core always passes a fully
set struct tm (using rtc_ktime_to_tm) to the .set_alarm callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-tx4939.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index 61c110b2045f..8497fceea27f 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -123,13 +123,6 @@ static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	unsigned long sec;
 	unsigned char buf[6];
 
-	if (alrm->time.tm_sec < 0 ||
-	    alrm->time.tm_min < 0 ||
-	    alrm->time.tm_hour < 0 ||
-	    alrm->time.tm_mday < 0 ||
-	    alrm->time.tm_mon < 0 ||
-	    alrm->time.tm_year < 0)
-		return -EINVAL;
 	rtc_tm_to_time(&alrm->time, &sec);
 	buf[0] = 0;
 	buf[1] = 0;
-- 
2.20.1


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

* [PATCH 2/4] rtc: tx4939: set range
  2019-03-03 22:21 [PATCH 1/4] rtc: tx4939: remove useless test Alexandre Belloni
@ 2019-03-03 22:21 ` Alexandre Belloni
  2019-03-03 22:21 ` [PATCH 3/4] rtc: tx4939: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
  2019-03-03 22:21 ` [PATCH 4/4] rtc: tx4939: use .set_time Alexandre Belloni
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2019-03-03 22:21 UTC (permalink / raw)
  To: linux-rtc; +Cc: Alexandre Belloni

The TX4939 RTC is a 48bit counter that counts two on every clock edge of
32.768 KHz oscillator clock so it counts 32bit seconds.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-tx4939.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index 8497fceea27f..b405818933fb 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -276,6 +276,7 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev)
 
 	rtc->ops = &tx4939_rtc_ops;
 	rtc->nvram_old_abi = true;
+	rtc->range_max = U32_MAX;
 
 	pdata->rtc = rtc;
 
-- 
2.20.1


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

* [PATCH 3/4] rtc: tx4939: switch to rtc_time64_to_tm/rtc_tm_to_time64
  2019-03-03 22:21 [PATCH 1/4] rtc: tx4939: remove useless test Alexandre Belloni
  2019-03-03 22:21 ` [PATCH 2/4] rtc: tx4939: set range Alexandre Belloni
@ 2019-03-03 22:21 ` Alexandre Belloni
  2019-03-03 22:21 ` [PATCH 4/4] rtc: tx4939: use .set_time Alexandre Belloni
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2019-03-03 22:21 UTC (permalink / raw)
  To: linux-rtc; +Cc: Alexandre Belloni

Call the 64bit versions of rtc_time_to_tm now that the range is enforced by
the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-tx4939.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index b405818933fb..8acb8adc11d7 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -111,7 +111,7 @@ static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm)
 	spin_unlock_irq(&pdata->lock);
 	sec = ((unsigned long)buf[5] << 24) | (buf[4] << 16) |
 		(buf[3] << 8) | buf[2];
-	rtc_time_to_tm(sec, tm);
+	rtc_time64_to_tm(sec, tm);
 	return 0;
 }
 
@@ -123,7 +123,7 @@ static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	unsigned long sec;
 	unsigned char buf[6];
 
-	rtc_tm_to_time(&alrm->time, &sec);
+	sec = rtc_tm_to_time64(&alrm->time);
 	buf[0] = 0;
 	buf[1] = 0;
 	buf[2] = sec;
@@ -166,7 +166,7 @@ static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	spin_unlock_irq(&pdata->lock);
 	sec = ((unsigned long)buf[5] << 24) | (buf[4] << 16) |
 		(buf[3] << 8) | buf[2];
-	rtc_time_to_tm(sec, &alrm->time);
+	rtc_time64_to_tm(sec, &alrm->time);
 	return rtc_valid_tm(&alrm->time);
 }
 
-- 
2.20.1


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

* [PATCH 4/4] rtc: tx4939: use .set_time
  2019-03-03 22:21 [PATCH 1/4] rtc: tx4939: remove useless test Alexandre Belloni
  2019-03-03 22:21 ` [PATCH 2/4] rtc: tx4939: set range Alexandre Belloni
  2019-03-03 22:21 ` [PATCH 3/4] rtc: tx4939: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
@ 2019-03-03 22:21 ` Alexandre Belloni
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2019-03-03 22:21 UTC (permalink / raw)
  To: linux-rtc; +Cc: Alexandre Belloni

Switch from .set_mmss to .set_time as the former is deprecated.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-tx4939.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index 8acb8adc11d7..404de455409b 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -65,10 +65,11 @@ static int tx4939_rtc_cmd(struct tx4939_rtc_reg __iomem *rtcreg, int cmd)
 	return 0;
 }
 
-static int tx4939_rtc_set_mmss(struct device *dev, unsigned long secs)
+static int tx4939_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
 	struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev);
 	struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
+	unsigned long secs = rtc_tm_to_time64(tm);
 	int i, ret;
 	unsigned char buf[6];
 
@@ -203,7 +204,7 @@ static const struct rtc_class_ops tx4939_rtc_ops = {
 	.read_time		= tx4939_rtc_read_time,
 	.read_alarm		= tx4939_rtc_read_alarm,
 	.set_alarm		= tx4939_rtc_set_alarm,
-	.set_mmss		= tx4939_rtc_set_mmss,
+	.set_time		= tx4939_rtc_set_time,
 	.alarm_irq_enable	= tx4939_rtc_alarm_irq_enable,
 };
 
-- 
2.20.1


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

end of thread, other threads:[~2019-03-03 22:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-03 22:21 [PATCH 1/4] rtc: tx4939: remove useless test Alexandre Belloni
2019-03-03 22:21 ` [PATCH 2/4] rtc: tx4939: set range Alexandre Belloni
2019-03-03 22:21 ` [PATCH 3/4] rtc: tx4939: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
2019-03-03 22:21 ` [PATCH 4/4] rtc: tx4939: use .set_time Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).