Message ID | 20220314141643.22184-10-u.kleine-koenig@pengutronix.de (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | clk: provide new devm helpers for prepared and enabled clocks | expand |
Hi Uwe, Le lun., mars 14 2022 at 15:16:36 +0100, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> a écrit : > With devm_clk_get_enabled() caring to disable (and unprepare) the > clock, > the probe function can be simplified accordingly. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Paul Cercueil <paul@crapouillou.net> Thanks! -Paul > --- > drivers/rtc/rtc-jz4740.c | 21 ++------------------- > 1 file changed, 2 insertions(+), 19 deletions(-) > > diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c > index 6e51df72fd65..9b7bb6ce93ee 100644 > --- a/drivers/rtc/rtc-jz4740.c > +++ b/drivers/rtc/rtc-jz4740.c > @@ -257,11 +257,6 @@ static void jz4740_rtc_power_off(void) > kernel_halt(); > } > > -static void jz4740_rtc_clk_disable(void *data) > -{ > - clk_disable_unprepare(data); > -} > - > static const struct of_device_id jz4740_rtc_of_match[] = { > { .compatible = "ingenic,jz4740-rtc", .data = (void *)ID_JZ4740 }, > { .compatible = "ingenic,jz4760-rtc", .data = (void *)ID_JZ4760 }, > @@ -329,24 +324,12 @@ static int jz4740_rtc_probe(struct > platform_device *pdev) > if (IS_ERR(rtc->base)) > return PTR_ERR(rtc->base); > > - clk = devm_clk_get(dev, "rtc"); > + clk = devm_clk_get_enabled(dev, "rtc"); > if (IS_ERR(clk)) { > - dev_err(dev, "Failed to get RTC clock\n"); > + dev_err(dev, "Failed to get enabled RTC clock\n"); > return PTR_ERR(clk); > } > > - ret = clk_prepare_enable(clk); > - if (ret) { > - dev_err(dev, "Failed to enable clock\n"); > - return ret; > - } > - > - ret = devm_add_action_or_reset(dev, jz4740_rtc_clk_disable, clk); > - if (ret) { > - dev_err(dev, "Failed to register devm action\n"); > - return ret; > - } > - > spin_lock_init(&rtc->lock); > > platform_set_drvdata(pdev, rtc); > -- > 2.35.1 >
diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c index 6e51df72fd65..9b7bb6ce93ee 100644 --- a/drivers/rtc/rtc-jz4740.c +++ b/drivers/rtc/rtc-jz4740.c @@ -257,11 +257,6 @@ static void jz4740_rtc_power_off(void) kernel_halt(); } -static void jz4740_rtc_clk_disable(void *data) -{ - clk_disable_unprepare(data); -} - static const struct of_device_id jz4740_rtc_of_match[] = { { .compatible = "ingenic,jz4740-rtc", .data = (void *)ID_JZ4740 }, { .compatible = "ingenic,jz4760-rtc", .data = (void *)ID_JZ4760 }, @@ -329,24 +324,12 @@ static int jz4740_rtc_probe(struct platform_device *pdev) if (IS_ERR(rtc->base)) return PTR_ERR(rtc->base); - clk = devm_clk_get(dev, "rtc"); + clk = devm_clk_get_enabled(dev, "rtc"); if (IS_ERR(clk)) { - dev_err(dev, "Failed to get RTC clock\n"); + dev_err(dev, "Failed to get enabled RTC clock\n"); return PTR_ERR(clk); } - ret = clk_prepare_enable(clk); - if (ret) { - dev_err(dev, "Failed to enable clock\n"); - return ret; - } - - ret = devm_add_action_or_reset(dev, jz4740_rtc_clk_disable, clk); - if (ret) { - dev_err(dev, "Failed to register devm action\n"); - return ret; - } - spin_lock_init(&rtc->lock); platform_set_drvdata(pdev, rtc);
With devm_clk_get_enabled() caring to disable (and unprepare) the clock, the probe function can be simplified accordingly. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/rtc/rtc-jz4740.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)