diff mbox series

[-next,04/11] gpio: lpc18xx: Use helper function devm_clk_get_enabled()

Message ID 20230818093018.1051434-5-lizetao1@huawei.com (mailing list archive)
State New, archived
Headers show
Series gpio: Use devm_clk_get_*() helper function to simplify the drivers. | expand

Commit Message

Li Zetao Aug. 18, 2023, 9:30 a.m. UTC
Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
prepared and enabled clocks"), devm_clk_get() and clk_prepare_enable()
can now be replaced by devm_clk_get_enabled() when the driver enables
(and possibly prepares) the clocks for the whole lifetime of the device.
Moreover, it is no longer necessary to unprepare and disable the clocks
explicitly.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/gpio/gpio-lpc18xx.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Andy Shevchenko Aug. 18, 2023, 2:07 p.m. UTC | #1
On Fri, Aug 18, 2023 at 05:30:11PM +0800, Li Zetao wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
> prepared and enabled clocks"), devm_clk_get() and clk_prepare_enable()
> can now be replaced by devm_clk_get_enabled() when the driver enables
> (and possibly prepares) the clocks for the whole lifetime of the device.
> Moreover, it is no longer necessary to unprepare and disable the clocks
> explicitly.

...

> -		dev_err(dev, "input clock not found\n");
> +		dev_err(dev,
> +			"input clock not found or unable to enable clock\n");

Do not alter the message right now. With the dev_err_probe() conversion it can
be done, if you wish. So it will be less churn.
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-lpc18xx.c b/drivers/gpio/gpio-lpc18xx.c
index ed3f653a1dfc..389f4d8befb0 100644
--- a/drivers/gpio/gpio-lpc18xx.c
+++ b/drivers/gpio/gpio-lpc18xx.c
@@ -352,18 +352,13 @@  static int lpc18xx_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(gc->base))
 		return PTR_ERR(gc->base);
 
-	gc->clk = devm_clk_get(dev, NULL);
+	gc->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(gc->clk)) {
-		dev_err(dev, "input clock not found\n");
+		dev_err(dev,
+			"input clock not found or unable to enable clock\n");
 		return PTR_ERR(gc->clk);
 	}
 
-	ret = clk_prepare_enable(gc->clk);
-	if (ret) {
-		dev_err(dev, "unable to enable clock\n");
-		return ret;
-	}
-
 	spin_lock_init(&gc->lock);
 
 	gc->gpio.parent = dev;
@@ -371,7 +366,6 @@  static int lpc18xx_gpio_probe(struct platform_device *pdev)
 	ret = devm_gpiochip_add_data(dev, &gc->gpio, gc);
 	if (ret) {
 		dev_err(dev, "failed to add gpio chip\n");
-		clk_disable_unprepare(gc->clk);
 		return ret;
 	}
 
@@ -388,8 +382,6 @@  static int lpc18xx_gpio_remove(struct platform_device *pdev)
 	if (gc->pin_ic)
 		irq_domain_remove(gc->pin_ic->domain);
 
-	clk_disable_unprepare(gc->clk);
-
 	return 0;
 }