Skip to contentSkip to conversation

rtc: da9052: convert to devm_rtc_allocate_device

PATCH In review Alexandre Belloni 2 participants 2 messages Mar 29, 2020 – Apr 1, 2020

Subsystems (2)
lore
Share & tools
lore

Alexandre Belloni

author maintainer
#0 lore raw

PATCH v2 1/1 rtc: da9052: convert to devm_rtc_allocate_device

This allows further improvement of the driver.

---

Changes in v2:
- avoid reordering rtc registration and irq request.

 drivers/rtc/rtc-da9052.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/rtc/rtc-da9052.c +7 -3
index 204eb7cf1aa4..e76561b8ad4c 100644
@@ -298,12 +298,16 @@ static int da9052_rtc_probe(struct platform_device *pdev)
 		rtc_err(rtc, "Failed to disable TICKS: %d\n", ret);
 
 	device_init_wakeup(&pdev->dev, true);
-	rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-				       &da9052_rtc_ops, THIS_MODULE);
-
+	rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(rtc->rtc))
 		return PTR_ERR(rtc->rtc);
 
+	rtc->rtc->ops = &da9052_rtc_ops;
+
+	ret = rtc_register_device(rtc->rtc);
+	if (ret)
+		return ret;
+
 	ret = da9052_request_irq(rtc->da9052, DA9052_IRQ_ALARM, "ALM",
 				da9052_rtc_irq, rtc);
 	if (ret != 0) {
Signature · 1 line
2.25.1
Acked-by on v2 1/1
#1 lore raw
Quoted 3 lines · Alexandre Belloni

This allows further improvement of the driver.

Quoted 35 lines

---

Changes in v2:
- avoid reordering rtc registration and irq request.

 drivers/rtc/rtc-da9052.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/rtc/rtc-da9052.c +7 -3
index 204eb7cf1aa4..e76561b8ad4c 100644
@@ -298,12 +298,16 @@ static int da9052_rtc_probe(struct platform_device
 *pdev)
 		rtc_err(rtc, "Failed to disable TICKS: %d\n", ret);
 
 	device_init_wakeup(&pdev->dev, true);
-	rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-				       &da9052_rtc_ops, THIS_MODULE);
-
+	rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(rtc->rtc))
 		return PTR_ERR(rtc->rtc);
 
+	rtc->rtc->ops = &da9052_rtc_ops;
+
+	ret = rtc_register_device(rtc->rtc);
+	if (ret)
+		return ret;
+
 	ret = da9052_request_irq(rtc->da9052, DA9052_IRQ_ALARM, "ALM",
 				da9052_rtc_irq, rtc);

if (ret != 0) {
--
2.25.1