From: Peng Fan Date: Wed, 5 Feb 2025 00:58:19 +0000 (+0800) Subject: rtc: stm32: Use resource managed API to simplify code X-Git-Tag: v6.15-rc1~33^2~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04572d18921d47939465d2cba32c19d05f27cda9;p=thirdparty%2Flinux.git rtc: stm32: Use resource managed API to simplify code Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the error handling code and 'driver.remove()' hook. Reviewed-by: Antonio Borneo Signed-off-by: Peng Fan Link: https://lore.kernel.org/r/20250205-rtc-cleanup-v1-1-66165678e089@nxp.com Signed-off-by: Alexandre Belloni --- diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c index a0564d4435690..1b715db471601 100644 --- a/drivers/rtc/rtc-stm32.c +++ b/drivers/rtc/rtc-stm32.c @@ -1143,11 +1143,11 @@ static int stm32_rtc_probe(struct platform_device *pdev) goto err; } - ret = device_init_wakeup(&pdev->dev, true); + ret = devm_device_init_wakeup(&pdev->dev); if (ret) goto err; - ret = dev_pm_set_wake_irq(&pdev->dev, rtc->irq_alarm); + ret = devm_pm_set_wake_irq(&pdev->dev, rtc->irq_alarm); if (ret) goto err; @@ -1208,9 +1208,6 @@ err_no_rtc_ck: if (rtc->data->need_dbp) regmap_update_bits(rtc->dbp, rtc->dbp_reg, rtc->dbp_mask, 0); - dev_pm_clear_wake_irq(&pdev->dev); - device_init_wakeup(&pdev->dev, false); - return ret; } @@ -1237,9 +1234,6 @@ static void stm32_rtc_remove(struct platform_device *pdev) /* Enable backup domain write protection if needed */ if (rtc->data->need_dbp) regmap_update_bits(rtc->dbp, rtc->dbp_reg, rtc->dbp_mask, 0); - - dev_pm_clear_wake_irq(&pdev->dev); - device_init_wakeup(&pdev->dev, false); } static int stm32_rtc_suspend(struct device *dev)