From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device()
and devm_rtc_register_device() pair instead.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
 drivers/rtc/rtc-stm32.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c
index d774aa18f57a..9d6be4fa885d 100644
--- a/drivers/rtc/rtc-stm32.c
+++ b/drivers/rtc/rtc-stm32.c
@@ -795,14 +795,11 @@ static int stm32_rtc_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, rtc);
 
-       rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, pdev->name,
-                                               &stm32_rtc_ops, THIS_MODULE);
-       if (IS_ERR(rtc->rtc_dev)) {
-               ret = PTR_ERR(rtc->rtc_dev);
-               dev_err(&pdev->dev, "rtc device registration failed, err=%d\n",
-                       ret);
-               goto err;
-       }
+       rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
+       if (IS_ERR(rtc->rtc_dev))
+               return PTR_ERR(rtc->rtc_dev);
+
+       rtc->rtc_dev->ops = &stm32_rtc_ops;
 
        /* Handle RTC alarm interrupts */
        ret = devm_request_threaded_irq(&pdev->dev, rtc->irq_alarm, NULL,
@@ -829,7 +826,12 @@ static int stm32_rtc_probe(struct platform_device *pdev)
                         (ver >> STM32_RTC_VERR_MINREV_SHIFT) & 0xF);
        }
 
+       ret = devm_rtc_register_device(rtc->rtc_dev);
+       if (ret)
+               goto err;
+
        return 0;
+
 err:
        if (rtc->data->has_pclk)
                clk_disable_unprepare(rtc->pclk);
-- 
2.29.1

Reply via email to