mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 0/2] gpio: Simplify using devm_clk_get_enabled()
@ 2024-08-20 12:16 Rong Qianfeng
  2024-08-20 12:16 ` [PATCH v1 1/2] gpio: stp-xway: " Rong Qianfeng
  2024-08-20 12:16 ` [PATCH v1 2/2] gpio: zynq: " Rong Qianfeng
  0 siblings, 2 replies; 7+ messages in thread
From: Rong Qianfeng @ 2024-08-20 12:16 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Shubhrajyoti Datta,
	Srinivas Neeli, Michal Simek, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: opensource.kernel, Rong Qianfeng

devm_clk_get_enabled() will call devm_clk_get() + clk_prepare_enable()
and the clock will automatically be disabled, unprepared and freed when
the device is unbound from the bus. So simplify .probe() and .remove()
accordingly.

version 1 changes
The changes for davinci have been removed, as they have already been
sent by Bartosz.

Rong Qianfeng (2):
  gpio: stp-xway: Simplify using devm_clk_get_enabled()
  gpio: zynq: Simplify using devm_clk_get_enabled()

 drivers/gpio/gpio-stp-xway.c | 10 ++--------
 drivers/gpio/gpio-zynq.c     | 10 +---------
 2 files changed, 3 insertions(+), 17 deletions(-)

-- 
2.39.0


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

* [PATCH v1 1/2] gpio: stp-xway: Simplify using devm_clk_get_enabled()
  2024-08-20 12:16 [PATCH v1 0/2] gpio: Simplify using devm_clk_get_enabled() Rong Qianfeng
@ 2024-08-20 12:16 ` Rong Qianfeng
  2024-09-02 10:31   ` Bartosz Golaszewski
  2024-08-20 12:16 ` [PATCH v1 2/2] gpio: zynq: " Rong Qianfeng
  1 sibling, 1 reply; 7+ messages in thread
From: Rong Qianfeng @ 2024-08-20 12:16 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Shubhrajyoti Datta,
	Srinivas Neeli, Michal Simek, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: opensource.kernel, Rong Qianfeng

Use devm_clk_get_enabled() simplify xway_stp_probe().

Signed-off-by: Rong Qianfeng <rongqianfeng@vivo.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.39.0


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

* [PATCH v1 2/2] gpio: zynq: Simplify using devm_clk_get_enabled()
  2024-08-20 12:16 [PATCH v1 0/2] gpio: Simplify using devm_clk_get_enabled() Rong Qianfeng
  2024-08-20 12:16 ` [PATCH v1 1/2] gpio: stp-xway: " Rong Qianfeng
@ 2024-08-20 12:16 ` Rong Qianfeng
  2024-09-02 10:32   ` Bartosz Golaszewski
  2024-09-02 11:59   ` Bartosz Golaszewski
  1 sibling, 2 replies; 7+ messages in thread
From: Rong Qianfeng @ 2024-08-20 12:16 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Shubhrajyoti Datta,
	Srinivas Neeli, Michal Simek, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: opensource.kernel, Rong Qianfeng

Use devm_clk_get_enabled() simplify zynq_gpio_probe() and zynq_gpio_remove().

Signed-off-by: Rong Qianfeng <rongqianfeng@vivo.com>
---
 drivers/gpio/gpio-zynq.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index 466e23031afc..1a42336dfc1d 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -940,16 +940,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;
-	}
-
 	spin_lock_init(&gpio->dirlock);
 
 	pm_runtime_set_active(&pdev->dev);
@@ -999,7 +993,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;
 }
@@ -1019,7 +1012,6 @@ static void 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);
 }
-- 
2.39.0


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

* Re: [PATCH v1 1/2] gpio: stp-xway: Simplify using devm_clk_get_enabled()
  2024-08-20 12:16 ` [PATCH v1 1/2] gpio: stp-xway: " Rong Qianfeng
@ 2024-09-02 10:31   ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2024-09-02 10:31 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Shubhrajyoti Datta,
	Srinivas Neeli, Michal Simek, linux-gpio, linux-kernel,
	linux-arm-kernel, Rong Qianfeng
  Cc: Bartosz Golaszewski, opensource.kernel

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Tue, 20 Aug 2024 20:16:50 +0800, Rong Qianfeng wrote:
> Use devm_clk_get_enabled() simplify xway_stp_probe().
> 
> 

Applied, thanks!

[1/2] gpio: stp-xway: Simplify using devm_clk_get_enabled()
      commit: ece70e79868c75d946819db4fba095c8c96ddb32

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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

* Re: [PATCH v1 2/2] gpio: zynq: Simplify using devm_clk_get_enabled()
  2024-08-20 12:16 ` [PATCH v1 2/2] gpio: zynq: " Rong Qianfeng
@ 2024-09-02 10:32   ` Bartosz Golaszewski
  2024-09-02 10:58     ` Michal Simek
  2024-09-02 11:59   ` Bartosz Golaszewski
  1 sibling, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2024-09-02 10:32 UTC (permalink / raw)
  To: Michal Simek
  Cc: Linus Walleij, Shubhrajyoti Datta, Srinivas Neeli, linux-gpio,
	linux-kernel, linux-arm-kernel, opensource.kernel, Rong Qianfeng

On Tue, Aug 20, 2024 at 2:17 PM Rong Qianfeng <rongqianfeng@vivo.com> wrote:
>
> Use devm_clk_get_enabled() simplify zynq_gpio_probe() and zynq_gpio_remove().
>
> Signed-off-by: Rong Qianfeng <rongqianfeng@vivo.com>
> ---

Michal,

This changes the order of operations in remove(), could you test it or
at least give your Ack here?

Bart

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

* Re: [PATCH v1 2/2] gpio: zynq: Simplify using devm_clk_get_enabled()
  2024-09-02 10:32   ` Bartosz Golaszewski
@ 2024-09-02 10:58     ` Michal Simek
  0 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2024-09-02 10:58 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Shubhrajyoti Datta, Srinivas Neeli, linux-gpio,
	linux-kernel, linux-arm-kernel, opensource.kernel, Rong Qianfeng

Hi Bart,

On 9/2/24 12:32, Bartosz Golaszewski wrote:
> On Tue, Aug 20, 2024 at 2:17 PM Rong Qianfeng <rongqianfeng@vivo.com> wrote:
>>
>> Use devm_clk_get_enabled() simplify zynq_gpio_probe() and zynq_gpio_remove().
>>
>> Signed-off-by: Rong Qianfeng <rongqianfeng@vivo.com>
>> ---
> 
> Michal,
> 
> This changes the order of operations in remove(), could you test it or
> at least give your Ack here?

Changes look good to me.
Acked-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal

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

* Re: [PATCH v1 2/2] gpio: zynq: Simplify using devm_clk_get_enabled()
  2024-08-20 12:16 ` [PATCH v1 2/2] gpio: zynq: " Rong Qianfeng
  2024-09-02 10:32   ` Bartosz Golaszewski
@ 2024-09-02 11:59   ` Bartosz Golaszewski
  1 sibling, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2024-09-02 11:59 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Shubhrajyoti Datta,
	Srinivas Neeli, Michal Simek, linux-gpio, linux-kernel,
	linux-arm-kernel, Rong Qianfeng
  Cc: Bartosz Golaszewski, opensource.kernel

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Tue, 20 Aug 2024 20:16:51 +0800, Rong Qianfeng wrote:
> Use devm_clk_get_enabled() simplify zynq_gpio_probe() and zynq_gpio_remove().
> 
> 

Applied, thanks!

[2/2] gpio: zynq: Simplify using devm_clk_get_enabled()
      commit: 8d2aaf4382b7c2ae4eae17c3eb71474eddbb5c4b

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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

end of thread, other threads:[~2024-09-02 11:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-20 12:16 [PATCH v1 0/2] gpio: Simplify using devm_clk_get_enabled() Rong Qianfeng
2024-08-20 12:16 ` [PATCH v1 1/2] gpio: stp-xway: " Rong Qianfeng
2024-09-02 10:31   ` Bartosz Golaszewski
2024-08-20 12:16 ` [PATCH v1 2/2] gpio: zynq: " Rong Qianfeng
2024-09-02 10:32   ` Bartosz Golaszewski
2024-09-02 10:58     ` Michal Simek
2024-09-02 11:59   ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®