rtc: omap: switch to rtc_register_device
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>
Thu, 12 Oct 2017 22:06:45 +0000 (00:06 +0200)
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>
Tue, 31 Oct 2017 16:31:13 +0000 (17:31 +0100)
This removes a possible race condition and crash and allows for further
improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
drivers/rtc/rtc-omap.c

index 3bdc041fc2e9caa86ac6398843439bd9c046d849..d56d937966dcbee58a1a8230ebc3205cd6ef01d5 100644 (file)
@@ -797,13 +797,14 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
        device_init_wakeup(&pdev->dev, true);
 
-       rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-                       &omap_rtc_ops, THIS_MODULE);
+       rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
        if (IS_ERR(rtc->rtc)) {
                ret = PTR_ERR(rtc->rtc);
                goto err;
        }
 
+       rtc->rtc->ops = &omap_rtc_ops;
+
        /* handle periodic and alarm irqs */
        ret = devm_request_irq(&pdev->dev, rtc->irq_timer, rtc_irq, 0,
                        dev_name(&rtc->rtc->dev), rtc);
@@ -834,6 +835,10 @@ static int omap_rtc_probe(struct platform_device *pdev)
                goto err;
        }
 
+       ret = rtc_register_device(rtc->rtc);
+       if (ret)
+               goto err;
+
        return 0;
 
 err: