linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers.
@ 2023-08-18  9:30 Li Zetao
  2023-08-18  9:30 ` [PATCH -next 01/11] gpio: cadence: Use helper function devm_clk_get_enabled() Li Zetao
                   ` (10 more replies)
  0 siblings, 11 replies; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

Commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
and enabled clocks") provides a a series of new helper function for
prepared and enabled clocks when a driver keeps a clock prepared
(or enabled) during the whole lifetime of the driver. So where drivers
get clocks and enable them immediately, it can be combined into a single
function devm_clk_get_*(). Moreover, the unprepare and disable function
has been registered to devm_clk_state, and before devm_clk_state is
released, the clocks will be unprepareed and disable, so it is unnecessary
to unprepare and disable clock explicitly when remove drivers or in the
error handling path.

Li Zetao (11):
  gpio: cadence: Use helper function devm_clk_get_enabled()
  gpio: davinci: Use helper function devm_clk_get_enabled()
  gpio: ftgpio010: Use helper function devm_clk_get_enabled()
  gpio: lpc18xx: Use helper function devm_clk_get_enabled()
  gpio: mb86s7x: Use helper function devm_clk_get_optional_enabled()
  gpio: mvebu: Use helper function devm_clk_get_enabled()
  gpio: mxc: Use helper function devm_clk_get_optional_enabled()
  gpio: omap: Use helper function devm_clk_get_prepared()
  gpio: stp-xway: Use helper function devm_clk_get_enabled()
  gpio: xilinx: Use helper function devm_clk_get_optional_enabled()
  gpio: zynq: Use helper function devm_clk_get_enabled()

 drivers/gpio/gpio-cadence.c   | 20 +++++---------------
 drivers/gpio/gpio-davinci.c   | 13 ++-----------
 drivers/gpio/gpio-ftgpio010.c | 29 +++++++----------------------
 drivers/gpio/gpio-lpc18xx.c   | 14 +++-----------
 drivers/gpio/gpio-mb86s7x.c   |  8 +-------
 drivers/gpio/gpio-mvebu.c     |  4 +---
 drivers/gpio/gpio-mxc.c       |  9 +--------
 drivers/gpio/gpio-omap.c      |  8 +-------
 drivers/gpio/gpio-stp-xway.c  | 10 ++--------
 drivers/gpio/gpio-xilinx.c    | 14 +++-----------
 drivers/gpio/gpio-zynq.c      | 13 +++----------
 11 files changed, 29 insertions(+), 113 deletions(-)

-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH -next 01/11] gpio: cadence: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 13:49   ` Andy Shevchenko
  2023-08-18  9:30 ` [PATCH -next 02/11] gpio: davinci: " Li Zetao
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

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-cadence.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-cadence.c b/drivers/gpio/gpio-cadence.c
index 3720b90cad10..a545baed9136 100644
--- a/drivers/gpio/gpio-cadence.c
+++ b/drivers/gpio/gpio-cadence.c
@@ -203,18 +203,12 @@ static int cdns_gpio_probe(struct platform_device *pdev)
 	cgpio->gc.request = cdns_gpio_request;
 	cgpio->gc.free = cdns_gpio_free;
 
-	cgpio->pclk = devm_clk_get(&pdev->dev, NULL);
+	cgpio->pclk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(cgpio->pclk)) {
 		ret = PTR_ERR(cgpio->pclk);
 		dev_err(&pdev->dev,
-			"Failed to retrieve peripheral clock, %d\n", ret);
-		goto err_revert_dir;
-	}
-
-	ret = clk_prepare_enable(cgpio->pclk);
-	if (ret) {
-		dev_err(&pdev->dev,
-			"Failed to enable the peripheral clock, %d\n", ret);
+			"Failed to retrieve and enable peripheral clock, %d\n",
+			ret);
 		goto err_revert_dir;
 	}
 
@@ -234,7 +228,7 @@ static int cdns_gpio_probe(struct platform_device *pdev)
 					     GFP_KERNEL);
 		if (!girq->parents) {
 			ret = -ENOMEM;
-			goto err_disable_clk;
+			goto err_revert_dir;
 		}
 		girq->parents[0] = irq;
 		girq->default_type = IRQ_TYPE_NONE;
@@ -244,7 +238,7 @@ static int cdns_gpio_probe(struct platform_device *pdev)
 	ret = devm_gpiochip_add_data(&pdev->dev, &cgpio->gc, cgpio);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
-		goto err_disable_clk;
+		goto err_revert_dir;
 	}
 
 	cgpio->bypass_orig = ioread32(cgpio->regs + CDNS_GPIO_BYPASS_MODE);
@@ -259,9 +253,6 @@ static int cdns_gpio_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, cgpio);
 	return 0;
 
-err_disable_clk:
-	clk_disable_unprepare(cgpio->pclk);
-
 err_revert_dir:
 	iowrite32(dir_prev, cgpio->regs + CDNS_GPIO_DIRECTION_MODE);
 
@@ -273,7 +264,6 @@ static int cdns_gpio_remove(struct platform_device *pdev)
 	struct cdns_gpio_chip *cgpio = platform_get_drvdata(pdev);
 
 	iowrite32(cgpio->bypass_orig, cgpio->regs + CDNS_GPIO_BYPASS_MODE);
-	clk_disable_unprepare(cgpio->pclk);
 
 	return 0;
 }
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 02/11] gpio: davinci: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  2023-08-18  9:30 ` [PATCH -next 01/11] gpio: cadence: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 14:03   ` Andy Shevchenko
  2023-08-18  9:30 ` [PATCH -next 03/11] gpio: ftgpio010: " Li Zetao
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

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-davinci.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 8db5717bdabe..23b5ae8cf2aa 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -477,7 +477,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
 {
 	unsigned	gpio, bank;
 	int		irq;
-	int		ret;
 	struct clk	*clk;
 	u32		binten = 0;
 	unsigned	ngpio;
@@ -502,21 +501,16 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
 
 	ngpio = pdata->ngpio;
 
-	clk = devm_clk_get(dev, "gpio");
+	clk = devm_clk_get_enabled(dev, "gpio");
 	if (IS_ERR(clk)) {
 		dev_err(dev, "Error %ld getting gpio clock\n", PTR_ERR(clk));
 		return PTR_ERR(clk);
 	}
 
-	ret = clk_prepare_enable(clk);
-	if (ret)
-		return ret;
-
 	if (!pdata->gpio_unbanked) {
 		irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0);
 		if (irq < 0) {
 			dev_err(dev, "Couldn't allocate IRQ numbers\n");
-			clk_disable_unprepare(clk);
 			return irq;
 		}
 
@@ -525,7 +519,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
 							chips);
 		if (!irq_domain) {
 			dev_err(dev, "Couldn't register an IRQ domain\n");
-			clk_disable_unprepare(clk);
 			return -ENODEV;
 		}
 	}
@@ -594,10 +587,8 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
 				       sizeof(struct
 					      davinci_gpio_irq_data),
 					      GFP_KERNEL);
-		if (!irqdata) {
-			clk_disable_unprepare(clk);
+		if (!irqdata)
 			return -ENOMEM;
-		}
 
 		irqdata->regs = g;
 		irqdata->bank_num = bank;
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 03/11] gpio: ftgpio010: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  2023-08-18  9:30 ` [PATCH -next 01/11] gpio: cadence: Use helper function devm_clk_get_enabled() Li Zetao
  2023-08-18  9:30 ` [PATCH -next 02/11] gpio: davinci: " Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 13:47   ` Andy Shevchenko
  2023-08-18  9:30 ` [PATCH -next 04/11] gpio: lpc18xx: " Li Zetao
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

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-ftgpio010.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/gpio/gpio-ftgpio010.c b/drivers/gpio/gpio-ftgpio010.c
index 5ce59dcf02e3..51724adf237a 100644
--- a/drivers/gpio/gpio-ftgpio010.c
+++ b/drivers/gpio/gpio-ftgpio010.c
@@ -253,18 +253,13 @@ static int ftgpio_gpio_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	g->clk = devm_clk_get(dev, NULL);
-	if (!IS_ERR(g->clk)) {
-		ret = clk_prepare_enable(g->clk);
-		if (ret)
-			return ret;
-	} else if (PTR_ERR(g->clk) == -EPROBE_DEFER) {
+	g->clk = devm_clk_get_enabled(dev, NULL);
+	if (PTR_ERR_OR_ZERO(g->clk) == -EPROBE_DEFER)
 		/*
 		 * Percolate deferrals, for anything else,
 		 * just live without the clocking.
 		 */
 		return PTR_ERR(g->clk);
-	}
 
 	ret = bgpio_init(&g->gc, dev, 4,
 			 g->base + GPIO_DATA_IN,
@@ -275,7 +270,7 @@ static int ftgpio_gpio_probe(struct platform_device *pdev)
 			 0);
 	if (ret) {
 		dev_err(dev, "unable to init generic GPIO\n");
-		goto dis_clk;
+		return ret;
 	}
 	g->gc.label = dev_name(dev);
 	g->gc.base = -1;
@@ -293,10 +288,9 @@ static int ftgpio_gpio_probe(struct platform_device *pdev)
 	girq->num_parents = 1;
 	girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
 				     GFP_KERNEL);
-	if (!girq->parents) {
-		ret = -ENOMEM;
-		goto dis_clk;
-	}
+	if (!girq->parents)
+		return -ENOMEM;
+
 	girq->default_type = IRQ_TYPE_NONE;
 	girq->handler = handle_bad_irq;
 	girq->parents[0] = irq;
@@ -311,25 +305,16 @@ static int ftgpio_gpio_probe(struct platform_device *pdev)
 
 	ret = devm_gpiochip_add_data(dev, &g->gc, g);
 	if (ret)
-		goto dis_clk;
+		return ret;
 
 	platform_set_drvdata(pdev, g);
 	dev_info(dev, "FTGPIO010 @%p registered\n", g->base);
 
 	return 0;
-
-dis_clk:
-	clk_disable_unprepare(g->clk);
-
-	return ret;
 }
 
 static int ftgpio_gpio_remove(struct platform_device *pdev)
 {
-	struct ftgpio_gpio *g = platform_get_drvdata(pdev);
-
-	clk_disable_unprepare(g->clk);
-
 	return 0;
 }
 
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 04/11] gpio: lpc18xx: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                   ` (2 preceding siblings ...)
  2023-08-18  9:30 ` [PATCH -next 03/11] gpio: ftgpio010: " Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 14:07   ` Andy Shevchenko
  2023-08-18  9:30 ` [PATCH -next 05/11] gpio: mb86s7x: Use helper function devm_clk_get_optional_enabled() Li Zetao
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

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(-)

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;
 }
 
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 05/11] gpio: mb86s7x: Use helper function devm_clk_get_optional_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                   ` (3 preceding siblings ...)
  2023-08-18  9:30 ` [PATCH -next 04/11] gpio: lpc18xx: " Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 14:09   ` Andy Shevchenko
  2023-08-18  9:30 ` [PATCH -next 06/11] gpio: mvebu: Use helper function devm_clk_get_enabled() Li Zetao
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
prepared and enabled clocks"), devm_clk_get_optional() and
clk_prepare_enable() can now be replaced by
devm_clk_get_optional_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-mb86s7x.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-mb86s7x.c b/drivers/gpio/gpio-mb86s7x.c
index ca7eb5e8bfaa..8f2abc914dfa 100644
--- a/drivers/gpio/gpio-mb86s7x.c
+++ b/drivers/gpio/gpio-mb86s7x.c
@@ -170,14 +170,10 @@ static int mb86s70_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(gchip->base))
 		return PTR_ERR(gchip->base);
 
-	gchip->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	gchip->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
 	if (IS_ERR(gchip->clk))
 		return PTR_ERR(gchip->clk);
 
-	ret = clk_prepare_enable(gchip->clk);
-	if (ret)
-		return ret;
-
 	spin_lock_init(&gchip->lock);
 
 	gchip->gc.direction_output = mb86s70_gpio_direction_output;
@@ -196,7 +192,6 @@ static int mb86s70_gpio_probe(struct platform_device *pdev)
 	ret = gpiochip_add_data(&gchip->gc, gchip);
 	if (ret) {
 		dev_err(&pdev->dev, "couldn't register gpio driver\n");
-		clk_disable_unprepare(gchip->clk);
 		return ret;
 	}
 
@@ -211,7 +206,6 @@ static int mb86s70_gpio_remove(struct platform_device *pdev)
 
 	acpi_gpiochip_free_interrupts(&gchip->gc);
 	gpiochip_remove(&gchip->gc);
-	clk_disable_unprepare(gchip->clk);
 
 	return 0;
 }
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 06/11] gpio: mvebu: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                   ` (4 preceding siblings ...)
  2023-08-18  9:30 ` [PATCH -next 05/11] gpio: mb86s7x: Use helper function devm_clk_get_optional_enabled() Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 13:55   ` Andy Shevchenko
  2023-08-18  9:30 ` [PATCH -next 07/11] gpio: mxc: Use helper function devm_clk_get_optional_enabled() Li Zetao
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

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-mvebu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 67497116ce27..e0c9b2976705 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -1163,10 +1163,8 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 		return id;
 	}
 
-	mvchip->clk = devm_clk_get(&pdev->dev, NULL);
 	/* Not all SoCs require a clock.*/
-	if (!IS_ERR(mvchip->clk))
-		clk_prepare_enable(mvchip->clk);
+	mvchip->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 
 	mvchip->soc_variant = soc_variant;
 	mvchip->chip.label = dev_name(&pdev->dev);
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 07/11] gpio: mxc: Use helper function devm_clk_get_optional_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                   ` (5 preceding siblings ...)
  2023-08-18  9:30 ` [PATCH -next 06/11] gpio: mvebu: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 13:59   ` Andy Shevchenko
  2023-08-21 12:12   ` Bartosz Golaszewski
  2023-08-18  9:30 ` [PATCH -next 08/11] gpio: omap: Use helper function devm_clk_get_prepared() Li Zetao
                   ` (3 subsequent siblings)
  10 siblings, 2 replies; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
prepared and enabled clocks"), devm_clk_get_optional() and
clk_prepare_enable() can now be replaced by
devm_clk_get_optional_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-mxc.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 004c6ad7ce52..4cb455b2bdee 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -452,16 +452,10 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 		return port->irq;
 
 	/* the controller clock is optional */
-	port->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	port->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
 	if (IS_ERR(port->clk))
 		return PTR_ERR(port->clk);
 
-	err = clk_prepare_enable(port->clk);
-	if (err) {
-		dev_err(&pdev->dev, "Unable to enable clock.\n");
-		return err;
-	}
-
 	if (of_device_is_compatible(np, "fsl,imx7d-gpio"))
 		port->power_off = true;
 
@@ -535,7 +529,6 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 out_bgio:
 	pm_runtime_disable(&pdev->dev);
 	pm_runtime_put_noidle(&pdev->dev);
-	clk_disable_unprepare(port->clk);
 	dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err);
 	return err;
 }
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 08/11] gpio: omap: Use helper function devm_clk_get_prepared()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                   ` (6 preceding siblings ...)
  2023-08-18  9:30 ` [PATCH -next 07/11] gpio: mxc: Use helper function devm_clk_get_optional_enabled() Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 15:00   ` Andy Shevchenko
  2023-08-18  9:30 ` [PATCH -next 09/11] gpio: stp-xway: Use helper function devm_clk_get_enabled() Li Zetao
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
prepared and enabled clocks"), devm_clk_get() and clk_prepare() can now be
replaced by devm_clk_get_prepared() 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-omap.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index a927680c66f8..c0131ee0f90c 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1450,13 +1450,11 @@ static int omap_gpio_probe(struct platform_device *pdev)
 	}
 
 	if (bank->dbck_flag) {
-		bank->dbck = devm_clk_get(dev, "dbclk");
+		bank->dbck = devm_clk_get_prepared(dev, "dbclk");
 		if (IS_ERR(bank->dbck)) {
 			dev_err(dev,
 				"Could not get gpio dbck. Disable debounce\n");
 			bank->dbck_flag = false;
-		} else {
-			clk_prepare(bank->dbck);
 		}
 	}
 
@@ -1474,8 +1472,6 @@ static int omap_gpio_probe(struct platform_device *pdev)
 	if (ret) {
 		pm_runtime_put_sync(dev);
 		pm_runtime_disable(dev);
-		if (bank->dbck_flag)
-			clk_unprepare(bank->dbck);
 		return ret;
 	}
 
@@ -1496,8 +1492,6 @@ static int omap_gpio_remove(struct platform_device *pdev)
 	cpu_pm_unregister_notifier(&bank->nb);
 	gpiochip_remove(&bank->chip);
 	pm_runtime_disable(&pdev->dev);
-	if (bank->dbck_flag)
-		clk_unprepare(bank->dbck);
 
 	return 0;
 }
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 09/11] gpio: stp-xway: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                   ` (7 preceding siblings ...)
  2023-08-18  9:30 ` [PATCH -next 08/11] gpio: omap: Use helper function devm_clk_get_prepared() Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 15:11   ` Andy Shevchenko
  2023-08-18  9:30 ` [PATCH -next 10/11] gpio: xilinx: Use helper function devm_clk_get_optional_enabled() Li Zetao
  2023-08-18  9:30 ` [PATCH -next 11/11] gpio: zynq: Use helper function devm_clk_get_enabled() Li Zetao
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

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-stp-xway.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
index 053d616f2e02..5a6406d1f03a 100644
--- a/drivers/gpio/gpio-stp-xway.c
+++ b/drivers/gpio/gpio-stp-xway.c
@@ -296,23 +296,17 @@ static int xway_stp_probe(struct platform_device *pdev)
 	if (!of_property_read_bool(pdev->dev.of_node, "lantiq,rising"))
 		chip->edge = XWAY_STP_FALLING;
 
-	clk = devm_clk_get(&pdev->dev, NULL);
+	clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
 		return PTR_ERR(clk);
 	}
 
-	ret = clk_prepare_enable(clk);
-	if (ret)
-		return ret;
-
 	xway_stp_hw_init(chip);
 
 	ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
-	if (ret) {
-		clk_disable_unprepare(clk);
+	if (ret)
 		return ret;
-	}
 
 	dev_info(&pdev->dev, "Init done\n");
 
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 10/11] gpio: xilinx: Use helper function devm_clk_get_optional_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                   ` (8 preceding siblings ...)
  2023-08-18  9:30 ` [PATCH -next 09/11] gpio: stp-xway: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 15:12   ` Andy Shevchenko
  2023-08-18  9:30 ` [PATCH -next 11/11] gpio: zynq: Use helper function devm_clk_get_enabled() Li Zetao
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
prepared and enabled clocks"), devm_clk_get_optional() and
clk_prepare_enable() can now be replaced by
devm_clk_get_optional_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-xilinx.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index a16945e8319e..4e4da07bf8a2 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -334,12 +334,9 @@ static int __maybe_unused xgpio_suspend(struct device *dev)
  */
 static int xgpio_remove(struct platform_device *pdev)
 {
-	struct xgpio_instance *gpio = platform_get_drvdata(pdev);
-
 	pm_runtime_get_sync(&pdev->dev);
 	pm_runtime_put_noidle(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	clk_disable_unprepare(gpio->clk);
 
 	return 0;
 }
@@ -647,15 +644,11 @@ static int xgpio_probe(struct platform_device *pdev)
 		return PTR_ERR(chip->regs);
 	}
 
-	chip->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	chip->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
 	if (IS_ERR(chip->clk))
-		return dev_err_probe(&pdev->dev, PTR_ERR(chip->clk), "input clock not found.\n");
+		return dev_err_probe(&pdev->dev, PTR_ERR(chip->clk),
+				     "input clock not found or failed to prepare clk\n");
 
-	status = clk_prepare_enable(chip->clk);
-	if (status < 0) {
-		dev_err(&pdev->dev, "Failed to prepare clk\n");
-		return status;
-	}
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
@@ -702,7 +695,6 @@ static int xgpio_probe(struct platform_device *pdev)
 err_pm_put:
 	pm_runtime_disable(&pdev->dev);
 	pm_runtime_put_noidle(&pdev->dev);
-	clk_disable_unprepare(chip->clk);
 	return status;
 }
 
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH -next 11/11] gpio: zynq: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                   ` (9 preceding siblings ...)
  2023-08-18  9:30 ` [PATCH -next 10/11] gpio: xilinx: Use helper function devm_clk_get_optional_enabled() Li Zetao
@ 2023-08-18  9:30 ` Li Zetao
  2023-08-18 15:13   ` Andy Shevchenko
  10 siblings, 1 reply; 24+ messages in thread
From: Li Zetao @ 2023-08-18  9:30 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek
  Cc: lizetao1, linux-gpio, linux-arm-kernel, linux-pwm, linux-omap

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-zynq.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index 0a7264aabe48..98cb38c95837 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -918,15 +918,10 @@ static int zynq_gpio_probe(struct platform_device *pdev)
 	chip->ngpio = gpio->p_data->ngpio;
 
 	/* Retrieve GPIO clock */
-	gpio->clk = devm_clk_get(&pdev->dev, NULL);
+	gpio->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(gpio->clk))
-		return dev_err_probe(&pdev->dev, PTR_ERR(gpio->clk), "input clock not found.\n");
-
-	ret = clk_prepare_enable(gpio->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "Unable to enable clock.\n");
-		return ret;
-	}
+		return dev_err_probe(&pdev->dev, PTR_ERR(gpio->clk),
+				     "input clock not found or unable to enable clock.\n");
 
 	spin_lock_init(&gpio->dirlock);
 
@@ -977,7 +972,6 @@ static int zynq_gpio_probe(struct platform_device *pdev)
 	pm_runtime_put(&pdev->dev);
 err_pm_dis:
 	pm_runtime_disable(&pdev->dev);
-	clk_disable_unprepare(gpio->clk);
 
 	return ret;
 }
@@ -997,7 +991,6 @@ static int zynq_gpio_remove(struct platform_device *pdev)
 	if (ret < 0)
 		dev_warn(&pdev->dev, "pm_runtime_get_sync() Failed\n");
 	gpiochip_remove(&gpio->chip);
-	clk_disable_unprepare(gpio->clk);
 	device_set_wakeup_capable(&pdev->dev, 0);
 	pm_runtime_disable(&pdev->dev);
 	return 0;
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 03/11] gpio: ftgpio010: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 ` [PATCH -next 03/11] gpio: ftgpio010: " Li Zetao
@ 2023-08-18 13:47   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 13:47 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:10PM +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.

...

> -	} else if (PTR_ERR(g->clk) == -EPROBE_DEFER) {
> +	g->clk = devm_clk_get_enabled(dev, NULL);
> +	if (PTR_ERR_OR_ZERO(g->clk) == -EPROBE_DEFER)
>  		/*
>  		 * Percolate deferrals, for anything else,
>  		 * just live without the clocking.
>  		 */
>  		return PTR_ERR(g->clk);
> -	}

It means you need to use _optional variant here and return whatever error you
get.

...

>  	platform_set_drvdata(pdev, g);

Do you now need this?

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 01/11] gpio: cadence: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 ` [PATCH -next 01/11] gpio: cadence: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18 13:49   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 13:49 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:08PM +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.

...

> -			"Failed to retrieve peripheral clock, %d\n", ret);
> +			"Failed to retrieve and enable peripheral clock, %d\n",

In some drivers you changed the message in some not.
I suggest to avoid changing messages for now and do this separately.
Also consider switching them to use dev_err_probe() instead.

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 06/11] gpio: mvebu: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 ` [PATCH -next 06/11] gpio: mvebu: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18 13:55   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 13:55 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:13PM +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.

...

> -	mvchip->clk = devm_clk_get(&pdev->dev, NULL);
>  	/* Not all SoCs require a clock.*/
> -	if (!IS_ERR(mvchip->clk))
> -		clk_prepare_enable(mvchip->clk);
> +	mvchip->clk = devm_clk_get_enabled(&pdev->dev, NULL);

The clk is only used in the PWM part, move it there and remove clk member from
the private struct.

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 07/11] gpio: mxc: Use helper function devm_clk_get_optional_enabled()
  2023-08-18  9:30 ` [PATCH -next 07/11] gpio: mxc: Use helper function devm_clk_get_optional_enabled() Li Zetao
@ 2023-08-18 13:59   ` Andy Shevchenko
  2023-08-21 12:12   ` Bartosz Golaszewski
  1 sibling, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 13:59 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:14PM +0800, Li Zetao wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
> prepared and enabled clocks"), devm_clk_get_optional() and
> clk_prepare_enable() can now be replaced by
> devm_clk_get_optional_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.

Reviewed-by: Andy Shevchenko <andy@kernel.org>


-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 02/11] gpio: davinci: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 ` [PATCH -next 02/11] gpio: davinci: " Li Zetao
@ 2023-08-18 14:03   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 14:03 UTC (permalink / raw)
  To: Li Zetao, Tony Lindgren
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:09PM +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.

It seems it fixes a bug that we try to remove the enabled clock on unbinding.
Maybe Tony can shed a light here. If this is the case, add a Fixes tag.
Otherwise it might be (undesired?) functional change and in any case has to
be mentioned in the commit message.

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 04/11] gpio: lpc18xx: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 ` [PATCH -next 04/11] gpio: lpc18xx: " Li Zetao
@ 2023-08-18 14:07   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 14:07 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

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.

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 05/11] gpio: mb86s7x: Use helper function devm_clk_get_optional_enabled()
  2023-08-18  9:30 ` [PATCH -next 05/11] gpio: mb86s7x: Use helper function devm_clk_get_optional_enabled() Li Zetao
@ 2023-08-18 14:09   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 14:09 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:12PM +0800, Li Zetao wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
> prepared and enabled clocks"), devm_clk_get_optional() and
> clk_prepare_enable() can now be replaced by
> devm_clk_get_optional_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.

With this the clk member in the private struct is not needed anymore.

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 08/11] gpio: omap: Use helper function devm_clk_get_prepared()
  2023-08-18  9:30 ` [PATCH -next 08/11] gpio: omap: Use helper function devm_clk_get_prepared() Li Zetao
@ 2023-08-18 15:00   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 15:00 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:15PM +0800, Li Zetao wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
> prepared and enabled clocks"), devm_clk_get() and clk_prepare() can now be
> replaced by devm_clk_get_prepared() 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.

The commit message isn't correct. Seems you copied'n'pasted from other cases.

Please, revisit.

Code wise looks legit to me.

With the commit message fixed
Reviewed-by: Andy Shevchenko <andy@kernel.org>

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 09/11] gpio: stp-xway: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 ` [PATCH -next 09/11] gpio: stp-xway: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18 15:11   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 15:11 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:16PM +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.

...

>  	ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
> -	if (ret) {
> -		clk_disable_unprepare(clk);
> +	if (ret)
>  		return ret;
> -	}
>  
>  	dev_info(&pdev->dev, "Init done\n");

Go further and simply

	return devm_gpiochip_add_data(...);

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 10/11] gpio: xilinx: Use helper function devm_clk_get_optional_enabled()
  2023-08-18  9:30 ` [PATCH -next 10/11] gpio: xilinx: Use helper function devm_clk_get_optional_enabled() Li Zetao
@ 2023-08-18 15:12   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 15:12 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:17PM +0800, Li Zetao wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
> prepared and enabled clocks"), devm_clk_get_optional() and
> clk_prepare_enable() can now be replaced by
> devm_clk_get_optional_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.

...

>  	if (IS_ERR(chip->clk))
> -		return dev_err_probe(&pdev->dev, PTR_ERR(chip->clk), "input clock not found.\n");
> +		return dev_err_probe(&pdev->dev, PTR_ERR(chip->clk),
> +				     "input clock not found or failed to prepare clk\n");

Don't alter message in this change.

...

Do you need to set driver data now?

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 11/11] gpio: zynq: Use helper function devm_clk_get_enabled()
  2023-08-18  9:30 ` [PATCH -next 11/11] gpio: zynq: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18 15:13   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2023-08-18 15:13 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, brgl, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 05:30:18PM +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.

...

> -		return dev_err_probe(&pdev->dev, PTR_ERR(gpio->clk), "input clock not found.\n");
> +		return dev_err_probe(&pdev->dev, PTR_ERR(gpio->clk),
> +				     "input clock not found or unable to enable clock.\n");

With this change dropped,
Reviewed-by: Andy Shevchenko <andy@kernel.org>

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH -next 07/11] gpio: mxc: Use helper function devm_clk_get_optional_enabled()
  2023-08-18  9:30 ` [PATCH -next 07/11] gpio: mxc: Use helper function devm_clk_get_optional_enabled() Li Zetao
  2023-08-18 13:59   ` Andy Shevchenko
@ 2023-08-21 12:12   ` Bartosz Golaszewski
  1 sibling, 0 replies; 24+ messages in thread
From: Bartosz Golaszewski @ 2023-08-21 12:12 UTC (permalink / raw)
  To: Li Zetao
  Cc: linus.walleij, andy, j-keerthy, vz, thierry.reding,
	u.kleine-koenig, grygorii.strashko, ssantosh, khilman,
	shubhrajyoti.datta, srinivas.neeli, michal.simek, linux-gpio,
	linux-arm-kernel, linux-pwm, linux-omap

On Fri, Aug 18, 2023 at 11:30 AM Li Zetao <lizetao1@huawei.com> wrote:
>
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
> prepared and enabled clocks"), devm_clk_get_optional() and
> clk_prepare_enable() can now be replaced by
> devm_clk_get_optional_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-mxc.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
> index 004c6ad7ce52..4cb455b2bdee 100644
> --- a/drivers/gpio/gpio-mxc.c
> +++ b/drivers/gpio/gpio-mxc.c
> @@ -452,16 +452,10 @@ static int mxc_gpio_probe(struct platform_device *pdev)
>                 return port->irq;
>
>         /* the controller clock is optional */
> -       port->clk = devm_clk_get_optional(&pdev->dev, NULL);
> +       port->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
>         if (IS_ERR(port->clk))
>                 return PTR_ERR(port->clk);
>
> -       err = clk_prepare_enable(port->clk);
> -       if (err) {
> -               dev_err(&pdev->dev, "Unable to enable clock.\n");
> -               return err;
> -       }
> -
>         if (of_device_is_compatible(np, "fsl,imx7d-gpio"))
>                 port->power_off = true;
>
> @@ -535,7 +529,6 @@ static int mxc_gpio_probe(struct platform_device *pdev)
>  out_bgio:
>         pm_runtime_disable(&pdev->dev);
>         pm_runtime_put_noidle(&pdev->dev);
> -       clk_disable_unprepare(port->clk);
>         dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err);
>         return err;
>  }
> --
> 2.34.1
>

Applied, thanks!

Bart

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-08-21 12:12 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-18  9:30 [PATCH -next 00/11] gpio: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
2023-08-18  9:30 ` [PATCH -next 01/11] gpio: cadence: Use helper function devm_clk_get_enabled() Li Zetao
2023-08-18 13:49   ` Andy Shevchenko
2023-08-18  9:30 ` [PATCH -next 02/11] gpio: davinci: " Li Zetao
2023-08-18 14:03   ` Andy Shevchenko
2023-08-18  9:30 ` [PATCH -next 03/11] gpio: ftgpio010: " Li Zetao
2023-08-18 13:47   ` Andy Shevchenko
2023-08-18  9:30 ` [PATCH -next 04/11] gpio: lpc18xx: " Li Zetao
2023-08-18 14:07   ` Andy Shevchenko
2023-08-18  9:30 ` [PATCH -next 05/11] gpio: mb86s7x: Use helper function devm_clk_get_optional_enabled() Li Zetao
2023-08-18 14:09   ` Andy Shevchenko
2023-08-18  9:30 ` [PATCH -next 06/11] gpio: mvebu: Use helper function devm_clk_get_enabled() Li Zetao
2023-08-18 13:55   ` Andy Shevchenko
2023-08-18  9:30 ` [PATCH -next 07/11] gpio: mxc: Use helper function devm_clk_get_optional_enabled() Li Zetao
2023-08-18 13:59   ` Andy Shevchenko
2023-08-21 12:12   ` Bartosz Golaszewski
2023-08-18  9:30 ` [PATCH -next 08/11] gpio: omap: Use helper function devm_clk_get_prepared() Li Zetao
2023-08-18 15:00   ` Andy Shevchenko
2023-08-18  9:30 ` [PATCH -next 09/11] gpio: stp-xway: Use helper function devm_clk_get_enabled() Li Zetao
2023-08-18 15:11   ` Andy Shevchenko
2023-08-18  9:30 ` [PATCH -next 10/11] gpio: xilinx: Use helper function devm_clk_get_optional_enabled() Li Zetao
2023-08-18 15:12   ` Andy Shevchenko
2023-08-18  9:30 ` [PATCH -next 11/11] gpio: zynq: Use helper function devm_clk_get_enabled() Li Zetao
2023-08-18 15:13   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).