* [PATCH 1/3] rtc: ls1x: switch to rtc_register_device
@ 2018-05-17 20:53 Alexandre Belloni
2018-05-17 20:53 ` [PATCH 2/3] rtc: ls1x: remove useless label and goto Alexandre Belloni
2018-05-17 20:53 ` [PATCH 3/3] rtc: ls1x: add range Alexandre Belloni
0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Belloni @ 2018-05-17 20:53 UTC (permalink / raw)
To: linux-rtc; +Cc: Jiaxun Yang, Huacai Chen, linux-kernel, Alexandre Belloni
This allows for future improvement of the driver.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ls1x.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c
index de86f9fabc11..609bd1d013f0 100644
--- a/drivers/rtc/rtc-ls1x.c
+++ b/drivers/rtc/rtc-ls1x.c
@@ -173,15 +173,15 @@ static int ls1x_rtc_probe(struct platform_device *pdev)
while (readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TTS)
usleep_range(1000, 3000);
- rtcdev = devm_rtc_device_register(&pdev->dev, "ls1x-rtc",
- &ls1x_rtc_ops , THIS_MODULE);
- if (IS_ERR(rtcdev)) {
- ret = PTR_ERR(rtcdev);
- goto err;
- }
+ rtcdev = devm_rtc_allocate_device(&pdev->dev);
+ if (IS_ERR(rtcdev))
+ return PTR_ERR(rtcdev);
platform_set_drvdata(pdev, rtcdev);
- return 0;
+ rtcdev->ops = &ls1x_rtc_ops;
+
+ return rtc_register_device(rtcdev);
+
err:
return ret;
}
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] rtc: ls1x: remove useless label and goto
2018-05-17 20:53 [PATCH 1/3] rtc: ls1x: switch to rtc_register_device Alexandre Belloni
@ 2018-05-17 20:53 ` Alexandre Belloni
2018-05-17 20:53 ` [PATCH 3/3] rtc: ls1x: add range Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2018-05-17 20:53 UTC (permalink / raw)
To: linux-rtc; +Cc: Jiaxun Yang, Huacai Chen, linux-kernel, Alexandre Belloni
The error handling in ls1x_rtc_probe used to release resources but since
it is using devm functions, it only returns a value. Make the code clearer
by returning directly instead of using goto.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ls1x.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c
index 609bd1d013f0..8aa3f223621c 100644
--- a/drivers/rtc/rtc-ls1x.c
+++ b/drivers/rtc/rtc-ls1x.c
@@ -148,15 +148,13 @@ static int ls1x_rtc_probe(struct platform_device *pdev)
{
struct rtc_device *rtcdev;
unsigned long v;
- int ret;
v = readl(SYS_COUNTER_CNTRL);
if (!(v & RTC_CNTR_OK)) {
dev_err(&pdev->dev, "rtc counters not working\n");
- ret = -ENODEV;
- goto err;
+ return -ENODEV;
}
- ret = -ETIMEDOUT;
+
/* set to 1 HZ if needed */
if (readl(SYS_TOYTRIM) != 32767) {
v = 0x100000;
@@ -165,7 +163,7 @@ static int ls1x_rtc_probe(struct platform_device *pdev)
if (!v) {
dev_err(&pdev->dev, "time out\n");
- goto err;
+ return -ETIMEDOUT;
}
writel(32767, SYS_TOYTRIM);
}
@@ -181,9 +179,6 @@ static int ls1x_rtc_probe(struct platform_device *pdev)
rtcdev->ops = &ls1x_rtc_ops;
return rtc_register_device(rtcdev);
-
-err:
- return ret;
}
static struct platform_driver ls1x_rtc_driver = {
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] rtc: ls1x: add range
2018-05-17 20:53 [PATCH 1/3] rtc: ls1x: switch to rtc_register_device Alexandre Belloni
2018-05-17 20:53 ` [PATCH 2/3] rtc: ls1x: remove useless label and goto Alexandre Belloni
@ 2018-05-17 20:53 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2018-05-17 20:53 UTC (permalink / raw)
To: linux-rtc; +Cc: Jiaxun Yang, Huacai Chen, linux-kernel, Alexandre Belloni
While the year in encoded on 32 bits in SYS_TOYWRITE1i/SYS_TOYREAD1. The
Loongson 1c datasheet states that the range is from 0 to 99.
The current code exceeds this range and seems to be working, I deduce that
the leap year algorithm will fail in 2100.
Anyway, alarm registers only encode the year on 14 bits so with alarm
support, the range will always be limited to 0 to 16383.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ls1x.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c
index 8aa3f223621c..f4c248655edd 100644
--- a/drivers/rtc/rtc-ls1x.c
+++ b/drivers/rtc/rtc-ls1x.c
@@ -177,6 +177,8 @@ static int ls1x_rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, rtcdev);
rtcdev->ops = &ls1x_rtc_ops;
+ rtcdev->range_min = RTC_TIMESTAMP_BEGIN_1900;
+ rtcdev->range_max = RTC_TIMESTAMP_END_2099;
return rtc_register_device(rtcdev);
}
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-17 20:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-17 20:53 [PATCH 1/3] rtc: ls1x: switch to rtc_register_device Alexandre Belloni
2018-05-17 20:53 ` [PATCH 2/3] rtc: ls1x: remove useless label and goto Alexandre Belloni
2018-05-17 20:53 ` [PATCH 3/3] rtc: ls1x: add range 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).