Use devm_clk_get_enabled() instead of clk functions in rtc-at91rm9200. Signed-off-by: Liao Yuanhong <liaoyuanhong@xxxxxxxx> --- v2:remove the global sclk variable. --- drivers/rtc/rtc-at91rm9200.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index c16fe711a0d9..4d909b840515 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c @@ -104,7 +104,6 @@ static bool suspended; static DEFINE_SPINLOCK(suspended_lock); static unsigned long cached_events; static u32 at91_rtc_imr; -static struct clk *sclk; static void at91_rtc_write_ier(u32 mask) { @@ -471,6 +470,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev) struct rtc_device *rtc; struct resource *regs; int ret = 0; + struct clk *sclk; at91_rtc_config = of_device_get_match_data(&pdev->dev); if (!at91_rtc_config) @@ -498,16 +498,10 @@ static int __init at91_rtc_probe(struct platform_device *pdev) return PTR_ERR(rtc); platform_set_drvdata(pdev, rtc); - sclk = devm_clk_get(&pdev->dev, NULL); + sclk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(sclk)) return PTR_ERR(sclk); - ret = clk_prepare_enable(sclk); - if (ret) { - dev_err(&pdev->dev, "Could not enable slow clock\n"); - return ret; - } - at91_rtc_write(AT91_RTC_CR, 0); at91_rtc_write(AT91_RTC_MR, at91_rtc_read(AT91_RTC_MR) & ~AT91_RTC_HRMOD); @@ -521,7 +515,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev) "at91_rtc", pdev); if (ret) { dev_err(&pdev->dev, "IRQ %d already in use.\n", irq); - goto err_clk; + return ret; } /* cpu init code should really have flagged this device as @@ -539,7 +533,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev) rtc->range_max = RTC_TIMESTAMP_END_2099; ret = devm_rtc_register_device(rtc); if (ret) - goto err_clk; + return ret; /* enable SECEV interrupt in order to initialize at91_rtc_upd_rdy * completion. @@ -548,11 +542,6 @@ static int __init at91_rtc_probe(struct platform_device *pdev) dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n"); return 0; - -err_clk: - clk_disable_unprepare(sclk); - - return ret; } /* @@ -564,8 +553,6 @@ static void __exit at91_rtc_remove(struct platform_device *pdev) at91_rtc_write_idr(AT91_RTC_ACKUPD | AT91_RTC_ALARM | AT91_RTC_SECEV | AT91_RTC_TIMEV | AT91_RTC_CALEV); - - clk_disable_unprepare(sclk); } static void at91_rtc_shutdown(struct platform_device *pdev) -- 2.25.1