The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v1] gpio: mvebu: Fix optional clock enable handling
@ 2026-07-07 16:00 Yuho Choi
  2026-07-08 11:53 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-07-07 16:00 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel, Yuho Choi

mvebu_gpio_probe() ignores clk_prepare_enable() failures and has no
matching disable path for later probe failures.

Use devm_clk_get_optional_enabled() so clock lookup and enable failures
are reported, and so devres disables the clock on cleanup. Reject PWM
setup when the optional clock is absent.

Fixes: de88747f514a ("gpio: mvebu: Add clk support to prevent lockup")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 drivers/gpio/gpio-mvebu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index c030d1f00abc..c63cdaa78ac1 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -1152,10 +1152,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 		return id;
 	}
 
-	mvchip->clk = devm_clk_get(&pdev->dev, NULL);
+	mvchip->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
 	/* Not all SoCs require a clock.*/
-	if (!IS_ERR(mvchip->clk))
-		clk_prepare_enable(mvchip->clk);
+	if (IS_ERR(mvchip->clk))
+		return PTR_ERR(mvchip->clk);
 
 	mvchip->soc_variant = soc_variant;
 	mvchip->chip.label = dev_name(&pdev->dev);
-- 
2.43.0


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

* Re: [PATCH v1] gpio: mvebu: Fix optional clock enable handling
  2026-07-07 16:00 [PATCH v1] gpio: mvebu: Fix optional clock enable handling Yuho Choi
@ 2026-07-08 11:53 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2026-07-08 11:53 UTC (permalink / raw)
  To: Yuho Choi; +Cc: linux-gpio, linux-kernel, Linus Walleij, Bartosz Golaszewski

On Tue, 7 Jul 2026 18:00:30 +0200, Yuho Choi <dbgh9129@gmail.com> said:
> mvebu_gpio_probe() ignores clk_prepare_enable() failures and has no
> matching disable path for later probe failures.
>
> Use devm_clk_get_optional_enabled() so clock lookup and enable failures
> are reported, and so devres disables the clock on cleanup. Reject PWM
> setup when the optional clock is absent.
>

That last sentance is not clear. Which code changes "reject PWM setup" exactly?

Bart

> Fixes: de88747f514a ("gpio: mvebu: Add clk support to prevent lockup")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
>  drivers/gpio/gpio-mvebu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index c030d1f00abc..c63cdaa78ac1 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -1152,10 +1152,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
>  		return id;
>  	}
>
> -	mvchip->clk = devm_clk_get(&pdev->dev, NULL);
> +	mvchip->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
>  	/* Not all SoCs require a clock.*/
> -	if (!IS_ERR(mvchip->clk))
> -		clk_prepare_enable(mvchip->clk);
> +	if (IS_ERR(mvchip->clk))
> +		return PTR_ERR(mvchip->clk);
>
>  	mvchip->soc_variant = soc_variant;
>  	mvchip->chip.label = dev_name(&pdev->dev);
> --
> 2.43.0
>
>

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

end of thread, other threads:[~2026-07-08 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 16:00 [PATCH v1] gpio: mvebu: Fix optional clock enable handling Yuho Choi
2026-07-08 11:53 ` Bartosz Golaszewski

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