From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de> To: Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, Alessandro Zummo <a.zummo@towertech.it>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Nicolas Ferre <nicolas.ferre@microchip.com>, Ludovic Desroches <ludovic.desroches@microchip.com> Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de, linux-rtc@vger.kernel.org Subject: [PATCH v5 4/6] rtc: at91sma9: Simplify using devm_clk_get_enabled() Date: Thu, 22 Apr 2021 08:57:24 +0200 [thread overview] Message-ID: <20210422065726.1646742-5-u.kleine-koenig@pengutronix.de> (raw) In-Reply-To: <20210422065726.1646742-1-u.kleine-koenig@pengutronix.de> devm_clk_get_enabled() returns the clk already (prepared and) enabled and the automatically called cleanup cares for disabling (and unpreparing). So simplify .probe() and .remove() accordingly. Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/rtc/rtc-at91sam9.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index 2216be429ab7..b52e7bd26303 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c @@ -374,21 +374,14 @@ static int at91_rtc_probe(struct platform_device *pdev) return -ENOMEM; } - rtc->sclk = devm_clk_get(&pdev->dev, NULL); + rtc->sclk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(rtc->sclk)) return PTR_ERR(rtc->sclk); - ret = clk_prepare_enable(rtc->sclk); - if (ret) { - dev_err(&pdev->dev, "Could not enable slow clock\n"); - return ret; - } - sclk_rate = clk_get_rate(rtc->sclk); if (!sclk_rate || sclk_rate > AT91_RTT_RTPRES) { dev_err(&pdev->dev, "Invalid slow clock rate\n"); - ret = -EINVAL; - goto err_clk; + return -EINVAL; } mr = rtt_readl(rtc, MR); @@ -406,7 +399,7 @@ static int at91_rtc_probe(struct platform_device *pdev) rtc->rtcdev = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtc->rtcdev)) { ret = PTR_ERR(rtc->rtcdev); - goto err_clk; + return ret; } rtc->rtcdev->ops = &at91_rtc_ops; @@ -418,7 +411,7 @@ static int at91_rtc_probe(struct platform_device *pdev) dev_name(&rtc->rtcdev->dev), rtc); if (ret) { dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq); - goto err_clk; + return ret; } /* NOTE: sam9260 rev A silicon has a ROM bug which resets the @@ -432,11 +425,6 @@ static int at91_rtc_probe(struct platform_device *pdev) dev_name(&rtc->rtcdev->dev)); return devm_rtc_register_device(rtc->rtcdev); - -err_clk: - clk_disable_unprepare(rtc->sclk); - - return ret; } /* @@ -450,8 +438,6 @@ static int at91_rtc_remove(struct platform_device *pdev) /* disable all interrupts */ rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)); - clk_disable_unprepare(rtc->sclk); - return 0; } -- 2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de> To: Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, Alessandro Zummo <a.zummo@towertech.it>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Nicolas Ferre <nicolas.ferre@microchip.com>, Ludovic Desroches <ludovic.desroches@microchip.com> Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de, linux-rtc@vger.kernel.org Subject: [PATCH v5 4/6] rtc: at91sma9: Simplify using devm_clk_get_enabled() Date: Thu, 22 Apr 2021 08:57:24 +0200 [thread overview] Message-ID: <20210422065726.1646742-5-u.kleine-koenig@pengutronix.de> (raw) In-Reply-To: <20210422065726.1646742-1-u.kleine-koenig@pengutronix.de> devm_clk_get_enabled() returns the clk already (prepared and) enabled and the automatically called cleanup cares for disabling (and unpreparing). So simplify .probe() and .remove() accordingly. Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/rtc/rtc-at91sam9.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index 2216be429ab7..b52e7bd26303 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c @@ -374,21 +374,14 @@ static int at91_rtc_probe(struct platform_device *pdev) return -ENOMEM; } - rtc->sclk = devm_clk_get(&pdev->dev, NULL); + rtc->sclk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(rtc->sclk)) return PTR_ERR(rtc->sclk); - ret = clk_prepare_enable(rtc->sclk); - if (ret) { - dev_err(&pdev->dev, "Could not enable slow clock\n"); - return ret; - } - sclk_rate = clk_get_rate(rtc->sclk); if (!sclk_rate || sclk_rate > AT91_RTT_RTPRES) { dev_err(&pdev->dev, "Invalid slow clock rate\n"); - ret = -EINVAL; - goto err_clk; + return -EINVAL; } mr = rtt_readl(rtc, MR); @@ -406,7 +399,7 @@ static int at91_rtc_probe(struct platform_device *pdev) rtc->rtcdev = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtc->rtcdev)) { ret = PTR_ERR(rtc->rtcdev); - goto err_clk; + return ret; } rtc->rtcdev->ops = &at91_rtc_ops; @@ -418,7 +411,7 @@ static int at91_rtc_probe(struct platform_device *pdev) dev_name(&rtc->rtcdev->dev), rtc); if (ret) { dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq); - goto err_clk; + return ret; } /* NOTE: sam9260 rev A silicon has a ROM bug which resets the @@ -432,11 +425,6 @@ static int at91_rtc_probe(struct platform_device *pdev) dev_name(&rtc->rtcdev->dev)); return devm_rtc_register_device(rtc->rtcdev); - -err_clk: - clk_disable_unprepare(rtc->sclk); - - return ret; } /* @@ -450,8 +438,6 @@ static int at91_rtc_remove(struct platform_device *pdev) /* disable all interrupts */ rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)); - clk_disable_unprepare(rtc->sclk); - return 0; } -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-04-22 6:57 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-22 6:57 [PATCH v5 0/6] clk: provide new devm helpers for prepared and enabled clocks Uwe Kleine-König 2021-04-22 6:57 ` Uwe Kleine-König 2021-04-22 6:57 ` [PATCH v5 1/6] clk: generalize devm_clk_get() a bit Uwe Kleine-König 2021-04-22 6:57 ` Uwe Kleine-König 2021-04-22 6:57 ` [PATCH v5 2/6] clk: Provide new devm_clk_helpers for prepared and enabled clocks Uwe Kleine-König 2021-04-22 6:57 ` Uwe Kleine-König 2021-04-22 6:57 ` [PATCH v5 3/6] pwm: atmel: Simplify using devm_clk_get_prepared() Uwe Kleine-König 2021-04-22 6:57 ` Uwe Kleine-König 2021-04-22 6:57 ` Uwe Kleine-König [this message] 2021-04-22 6:57 ` [PATCH v5 4/6] rtc: at91sma9: Simplify using devm_clk_get_enabled() Uwe Kleine-König 2021-04-22 8:01 ` Alexander Dahl 2021-04-22 8:01 ` Alexander Dahl 2021-04-22 15:39 ` Uwe Kleine-König 2021-04-22 15:39 ` Uwe Kleine-König 2021-04-22 6:57 ` [PATCH v5 5/6] i2c: imx: Simplify using devm_clk_get_enableded() Uwe Kleine-König 2021-04-22 6:57 ` Uwe Kleine-König 2021-04-22 16:35 ` Uwe Kleine-König 2021-04-22 16:35 ` Uwe Kleine-König 2021-04-22 6:57 ` [PATCH v5 6/6] spi: davinci: Simplify using devm_clk_get_enabled() Uwe Kleine-König 2021-04-22 6:57 ` Uwe Kleine-König
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210422065726.1646742-5-u.kleine-koenig@pengutronix.de \ --to=u.kleine-koenig@pengutronix.de \ --cc=a.zummo@towertech.it \ --cc=alexandre.belloni@bootlin.com \ --cc=kernel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-clk@vger.kernel.org \ --cc=linux-rtc@vger.kernel.org \ --cc=ludovic.desroches@microchip.com \ --cc=mturquette@baylibre.com \ --cc=nicolas.ferre@microchip.com \ --cc=sboyd@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.