* [PATCH 1/3] rtc: tps65910: fix possible race condition
@ 2018-05-17 20:26 Alexandre Belloni
2018-05-17 20:26 ` [PATCH 2/3] rtc: tps65910: allow platform power up Alexandre Belloni
2018-05-17 20:26 ` [PATCH 3/3] rtc: tps65910: add range Alexandre Belloni
0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Belloni @ 2018-05-17 20:26 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.
Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before requesting the IRQ.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-tps65910.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c
index d0244d7979fc..a56b526db89a 100644
--- a/drivers/rtc/rtc-tps65910.c
+++ b/drivers/rtc/rtc-tps65910.c
@@ -380,6 +380,10 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
if (!tps_rtc)
return -ENOMEM;
+ tps_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+ if (IS_ERR(tps_rtc->rtc))
+ return PTR_ERR(tps_rtc->rtc);
+
/* Clear pending interrupts */
ret = regmap_read(tps65910->regmap, TPS65910_RTC_STATUS, &rtc_reg);
if (ret < 0)
@@ -421,10 +425,10 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
tps_rtc->irq = irq;
device_set_wakeup_capable(&pdev->dev, 1);
- tps_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
- &tps65910_rtc_ops, THIS_MODULE);
- if (IS_ERR(tps_rtc->rtc)) {
- ret = PTR_ERR(tps_rtc->rtc);
+ tps_rtc->rtc->ops = &tps65910_rtc_ops;
+
+ ret = rtc_register_device(tps_rtc->rtc);
+ if (ret) {
dev_err(&pdev->dev, "RTC device register: err %d\n", ret);
return ret;
}
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] rtc: tps65910: allow platform power up
2018-05-17 20:26 [PATCH 1/3] rtc: tps65910: fix possible race condition Alexandre Belloni
@ 2018-05-17 20:26 ` Alexandre Belloni
2018-05-17 20:26 ` [PATCH 3/3] rtc: tps65910: add range Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2018-05-17 20:26 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
Currently, the IRQs are disabled when the rtc driver is removed (e.g. when
shutting down the platform).
This means that the RTC will be unable to power up the platform.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-tps65910.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c
index a56b526db89a..819d2d0957b4 100644
--- a/drivers/rtc/rtc-tps65910.c
+++ b/drivers/rtc/rtc-tps65910.c
@@ -436,17 +436,6 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
return 0;
}
-/*
- * Disable tps65910 RTC interrupts.
- * Sets status flag to free.
- */
-static int tps65910_rtc_remove(struct platform_device *pdev)
-{
- tps65910_rtc_alarm_irq_enable(&pdev->dev, 0);
-
- return 0;
-}
-
#ifdef CONFIG_PM_SLEEP
static int tps65910_rtc_suspend(struct device *dev)
{
@@ -472,7 +461,6 @@ static SIMPLE_DEV_PM_OPS(tps65910_rtc_pm_ops, tps65910_rtc_suspend,
static struct platform_driver tps65910_rtc_driver = {
.probe = tps65910_rtc_probe,
- .remove = tps65910_rtc_remove,
.driver = {
.name = "tps65910-rtc",
.pm = &tps65910_rtc_pm_ops,
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] rtc: tps65910: add range
2018-05-17 20:26 [PATCH 1/3] rtc: tps65910: fix possible race condition Alexandre Belloni
2018-05-17 20:26 ` [PATCH 2/3] rtc: tps65910: allow platform power up Alexandre Belloni
@ 2018-05-17 20:26 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2018-05-17 20:26 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
The tps65910 RTC can support dates from 01/01/2000 to 31/12/2099.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-tps65910.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c
index 819d2d0957b4..a9bbd022aeef 100644
--- a/drivers/rtc/rtc-tps65910.c
+++ b/drivers/rtc/rtc-tps65910.c
@@ -426,6 +426,8 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
device_set_wakeup_capable(&pdev->dev, 1);
tps_rtc->rtc->ops = &tps65910_rtc_ops;
+ tps_rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
+ tps_rtc->rtc->range_max = RTC_TIMESTAMP_END_2099;
ret = rtc_register_device(tps_rtc->rtc);
if (ret) {
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-17 20:26 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:26 [PATCH 1/3] rtc: tps65910: fix possible race condition Alexandre Belloni
2018-05-17 20:26 ` [PATCH 2/3] rtc: tps65910: allow platform power up Alexandre Belloni
2018-05-17 20:26 ` [PATCH 3/3] rtc: tps65910: 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).