* [PATCH 1/4] rtc: pm8xxx: convert to devm_rtc_allocate_device
@ 2020-03-06 7:37 Alexandre Belloni
2020-03-06 7:37 ` [PATCH 2/4] rtc: pm8xxx: set range Alexandre Belloni
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexandre Belloni @ 2020-03-06 7:37 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel
This allows further improvement of the driver. Also remove the unnecessary
error string as the core will already display error messages.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pm8xxx.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 07ea1be3abb9..b97333c95e53 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -486,13 +486,11 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, 1);
/* Register the RTC device */
- rtc_dd->rtc = devm_rtc_device_register(&pdev->dev, "pm8xxx_rtc",
- &pm8xxx_rtc_ops, THIS_MODULE);
- if (IS_ERR(rtc_dd->rtc)) {
- dev_err(&pdev->dev, "%s: RTC registration failed (%ld)\n",
- __func__, PTR_ERR(rtc_dd->rtc));
+ rtc_dd->rtc = devm_rtc_allocate_device(&pdev->dev);
+ if (IS_ERR(rtc_dd->rtc))
return PTR_ERR(rtc_dd->rtc);
- }
+
+ rtc_dd->rtc->ops = &pm8xxx_rtc_ops;
/* Request the alarm IRQ */
rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->rtc_alarm_irq,
@@ -504,9 +502,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
return rc;
}
- dev_dbg(&pdev->dev, "Probe success !!\n");
-
- return 0;
+ return rtc_register_device(rtc_dd->rtc);
}
#ifdef CONFIG_PM_SLEEP
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/4] rtc: pm8xxx: set range
2020-03-06 7:37 [PATCH 1/4] rtc: pm8xxx: convert to devm_rtc_allocate_device Alexandre Belloni
@ 2020-03-06 7:37 ` Alexandre Belloni
2020-03-06 7:37 ` [PATCH 3/4] rtc: pm8xxx: : switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
2020-03-06 7:37 ` [PATCH 4/4] rtc: pm8xxx: stop validating valid alarm time Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2020-03-06 7:37 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel
The pm8xxx are 32bit seconds counter.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pm8xxx.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index b97333c95e53..71bd56d32c90 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -491,6 +491,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
return PTR_ERR(rtc_dd->rtc);
rtc_dd->rtc->ops = &pm8xxx_rtc_ops;
+ rtc_dd->rtc->range_max = U32_MAX;
/* Request the alarm IRQ */
rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->rtc_alarm_irq,
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/4] rtc: pm8xxx: : switch to rtc_time64_to_tm/rtc_tm_to_time64
2020-03-06 7:37 [PATCH 1/4] rtc: pm8xxx: convert to devm_rtc_allocate_device Alexandre Belloni
2020-03-06 7:37 ` [PATCH 2/4] rtc: pm8xxx: set range Alexandre Belloni
@ 2020-03-06 7:37 ` Alexandre Belloni
2020-03-06 7:37 ` [PATCH 4/4] rtc: pm8xxx: stop validating valid alarm time Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2020-03-06 7:37 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel
Call the 64bit versions of rtc_tm time conversion.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pm8xxx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 71bd56d32c90..2da0d80224c3 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -84,7 +84,7 @@ 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);
dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs);
@@ -208,7 +208,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
secs = value[0] | (value[1] << 8) | (value[2] << 16) |
((unsigned long)value[3] << 24);
- rtc_time_to_tm(secs, tm);
+ rtc_time64_to_tm(secs, tm);
dev_dbg(dev, "secs = %lu, h:m:s == %ptRt, y-m-d = %ptRdr\n", secs, tm, tm);
@@ -224,7 +224,7 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
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;
@@ -280,7 +280,7 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
secs = value[0] | (value[1] << 8) | (value[2] << 16) |
((unsigned long)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) {
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 4/4] rtc: pm8xxx: stop validating valid alarm time
2020-03-06 7:37 [PATCH 1/4] rtc: pm8xxx: convert to devm_rtc_allocate_device Alexandre Belloni
2020-03-06 7:37 ` [PATCH 2/4] rtc: pm8xxx: set range Alexandre Belloni
2020-03-06 7:37 ` [PATCH 3/4] rtc: pm8xxx: : switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
@ 2020-03-06 7:37 ` Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2020-03-06 7:37 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel
rtc_time64_to_tm never generates an invalid rtc_tm, stop validating it.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pm8xxx.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 2da0d80224c3..e3d9abb2134e 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -282,12 +282,6 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
rtc_time64_to_tm(secs, &alarm->time);
- rc = rtc_valid_tm(&alarm->time);
- if (rc < 0) {
- dev_err(dev, "Invalid alarm time read from RTC\n");
- return rc;
- }
-
dev_dbg(dev, "Alarm set for - h:m:s=%ptRt, y-m-d=%ptRdr\n",
&alarm->time, &alarm->time);
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-06 7:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-06 7:37 [PATCH 1/4] rtc: pm8xxx: convert to devm_rtc_allocate_device Alexandre Belloni
2020-03-06 7:37 ` [PATCH 2/4] rtc: pm8xxx: set range Alexandre Belloni
2020-03-06 7:37 ` [PATCH 3/4] rtc: pm8xxx: : switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
2020-03-06 7:37 ` [PATCH 4/4] rtc: pm8xxx: stop validating valid alarm 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).