* [PATCH 1/3] rtc: cpcap: convert to devm_rtc_allocate_device
@ 2020-03-06 1:57 Alexandre Belloni
2020-03-06 1:57 ` [PATCH 2/3] rtc: cpcap: set range Alexandre Belloni
2020-03-06 1:57 ` [PATCH 3/3] rtc: cpcap: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Belloni @ 2020-03-06 1:57 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel
This allows further improvement of the driver.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
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 6a3b70fd7e1f..35f0717661b3 100644
--- a/drivers/rtc/rtc-cpcap.c
+++ b/drivers/rtc/rtc-cpcap.c
@@ -256,12 +256,12 @@ static int cpcap_rtc_probe(struct platform_device *pdev)
return -ENODEV;
platform_set_drvdata(pdev, rtc);
- rtc->rtc_dev = devm_rtc_device_register(dev, "cpcap_rtc",
- &cpcap_rtc_ops, THIS_MODULE);
-
+ rtc->rtc_dev = devm_rtc_allocate_device(dev);
if (IS_ERR(rtc->rtc_dev))
return PTR_ERR(rtc->rtc_dev);
+ rtc->rtc_dev->ops = &cpcap_rtc_ops;
+
err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor);
if (err)
return err;
@@ -298,7 +298,7 @@ static int cpcap_rtc_probe(struct platform_device *pdev)
/* ignore error and continue without wakeup support */
}
- return 0;
+ return rtc_register_device(rtc->rtc_dev);
}
static const struct of_device_id cpcap_rtc_of_match[] = {
--
2.24.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] rtc: cpcap: set range
2020-03-06 1:57 [PATCH 1/3] rtc: cpcap: convert to devm_rtc_allocate_device Alexandre Belloni
@ 2020-03-06 1:57 ` Alexandre Belloni
2020-03-06 1:57 ` [PATCH 3/3] rtc: cpcap: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2020-03-06 1:57 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel
The CPCAP rtc is a 14bit day counter plus a 17bit seconds counter.
Note that this failed on Nov 10 2014 so it is very likely this driver as
never been used since.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-cpcap.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c
index 35f0717661b3..38f949730b1b 100644
--- a/drivers/rtc/rtc-cpcap.c
+++ b/drivers/rtc/rtc-cpcap.c
@@ -261,6 +261,7 @@ static int cpcap_rtc_probe(struct platform_device *pdev)
return PTR_ERR(rtc->rtc_dev);
rtc->rtc_dev->ops = &cpcap_rtc_ops;
+ rtc->rtc_dev->range_max = (1 << 14) * SECS_PER_DAY - 1;
err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor);
if (err)
--
2.24.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] rtc: cpcap: switch to rtc_time64_to_tm/rtc_tm_to_time64
2020-03-06 1:57 [PATCH 1/3] rtc: cpcap: convert to devm_rtc_allocate_device Alexandre Belloni
2020-03-06 1:57 ` [PATCH 2/3] rtc: cpcap: set range Alexandre Belloni
@ 2020-03-06 1:57 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2020-03-06 1:57 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-cpcap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c
index 38f949730b1b..a603f1f21125 100644
--- a/drivers/rtc/rtc-cpcap.c
+++ b/drivers/rtc/rtc-cpcap.c
@@ -56,14 +56,14 @@ static void cpcap2rtc_time(struct rtc_time *rtc, struct cpcap_time *cpcap)
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;
- rtc_tm_to_time(rtc, &time);
+ time = rtc_tm_to_time64(rtc);
cpcap->day = time / SECS_PER_DAY;
time %= SECS_PER_DAY;
--
2.24.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-06 1:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-06 1:57 [PATCH 1/3] rtc: cpcap: convert to devm_rtc_allocate_device Alexandre Belloni
2020-03-06 1:57 ` [PATCH 2/3] rtc: cpcap: set range Alexandre Belloni
2020-03-06 1:57 ` [PATCH 3/3] rtc: cpcap: switch to rtc_time64_to_tm/rtc_tm_to_time64 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).