Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] gpio: omap: do not unprepare the debounce clock twice on probe failure
@ 2026-11-24  8:52 Cong Nguyen
  2026-11-24  9:30 ` Andreas Kemnade
  2026-11-24  9:33 ` Sverdlin, Alexander
  0 siblings, 2 replies; 3+ messages in thread
From: Cong Nguyen @ 2026-11-24  8:52 UTC (permalink / raw)
  To: Grygorii Strashko, Santosh Shilimkar, Kevin Hilman, Linus Walleij,
	Bartosz Golaszewski
  Cc: Alexander Sverdlin, Jiawen Liu, linux-omap, linux-gpio,
	linux-kernel

The debounce clock is now obtained with devm_clk_get_prepared(), so
devres unprepares it when probe fails or the device is unbound. The error
path added for a failing pm_runtime_resume_and_get() still calls
clk_unprepare() on the same clock by hand.

When pm_runtime_resume_and_get() fails and a debounce clock is present,
the clock is unprepared twice. The second clk_unprepare() warns that the
clock is already unprepared.

Drop the manual clk_unprepare().

This issue was found by auditing the driver with an LLM coding assistant.

Fixes: 9df982f1f283 ("gpio: omap: handle debounce clock preparation failure")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
 drivers/gpio/gpio-omap.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 0da628ae77be..0af26c3f7197 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1463,8 +1463,6 @@ static int omap_gpio_probe(struct platform_device *pdev)
 	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0) {
 		pm_runtime_disable(dev);
-		if (bank->dbck_flag)
-			clk_unprepare(bank->dbck);
 		return ret;
 	}
 
-- 
2.25.1


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

* Re: [PATCH] gpio: omap: do not unprepare the debounce clock twice on probe failure
  2026-11-24  8:52 [PATCH] gpio: omap: do not unprepare the debounce clock twice on probe failure Cong Nguyen
@ 2026-11-24  9:30 ` Andreas Kemnade
  2026-11-24  9:33 ` Sverdlin, Alexander
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Kemnade @ 2026-11-24  9:30 UTC (permalink / raw)
  To: Cong Nguyen
  Cc: Grygorii Strashko, Santosh Shilimkar, Kevin Hilman, Linus Walleij,
	Bartosz Golaszewski, Alexander Sverdlin, Jiawen Liu, linux-omap,
	linux-gpio, linux-kernel

On Tue, 24 Nov 2026 15:52:31 +0700
Cong Nguyen <congnt264@gmail.com> wrote:

> The debounce clock is now obtained with devm_clk_get_prepared(), so
> devres unprepares it when probe fails or the device is unbound. The error
> path added for a failing pm_runtime_resume_and_get() still calls
> clk_unprepare() on the same clock by hand.
> 
> When pm_runtime_resume_and_get() fails and a debounce clock is present,
> the clock is unprepared twice. The second clk_unprepare() warns that the
> clock is already unprepared.
> 
> Drop the manual clk_unprepare().
> 
> This issue was found by auditing the driver with an LLM coding assistant.
> 
> Fixes: 9df982f1f283 ("gpio: omap: handle debounce clock preparation failure")
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>

Reviewed-by: Andreas Kemnade <andreas@kemnade.info>
> ---
>  drivers/gpio/gpio-omap.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index 0da628ae77be..0af26c3f7197 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1463,8 +1463,6 @@ static int omap_gpio_probe(struct platform_device *pdev)
>  	ret = pm_runtime_resume_and_get(dev);
>  	if (ret < 0) {
>  		pm_runtime_disable(dev);
> -		if (bank->dbck_flag)
> -			clk_unprepare(bank->dbck);
>  		return ret;
>  	}
>  


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

* Re: [PATCH] gpio: omap: do not unprepare the debounce clock twice on probe failure
  2026-11-24  8:52 [PATCH] gpio: omap: do not unprepare the debounce clock twice on probe failure Cong Nguyen
  2026-11-24  9:30 ` Andreas Kemnade
@ 2026-11-24  9:33 ` Sverdlin, Alexander
  1 sibling, 0 replies; 3+ messages in thread
From: Sverdlin, Alexander @ 2026-11-24  9:33 UTC (permalink / raw)
  To: linusw@kernel.org, ssantosh@kernel.org, brgl@kernel.org,
	khilman@kernel.org, congnt264@gmail.com, grygorii.strashko@ti.com
  Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	1298662399@qq.com, linux-omap@vger.kernel.org

Hi Cong,

thanks for the fix!

On Tue, 2026-11-24 at 15:52 +0700, Cong Nguyen wrote:
> The debounce clock is now obtained with devm_clk_get_prepared(), so
> devres unprepares it when probe fails or the device is unbound. The error
> path added for a failing pm_runtime_resume_and_get() still calls
> clk_unprepare() on the same clock by hand.
> 
> When pm_runtime_resume_and_get() fails and a debounce clock is present,
> the clock is unprepared twice. The second clk_unprepare() warns that the
> clock is already unprepared.
> 
> Drop the manual clk_unprepare().
> 
> This issue was found by auditing the driver with an LLM coding assistant.
> 
> Fixes: 9df982f1f283 ("gpio: omap: handle debounce clock preparation failure")
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>

looks correct to me,
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>

Looks like the issue crept in because of the tight merges of
05be1a99d6d68 ("gpio: omap: Propagate runtime PM failures in probe and request"),
present in v7.4-rc3 (next-20261104) and the following merge of 9df982f1f283
("gpio: omap: handle debounce clock preparation failure") into next-20261119,
which wasn't based on at least v7.4-rc3.

> ---
>  drivers/gpio/gpio-omap.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index 0da628ae77be..0af26c3f7197 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1463,8 +1463,6 @@ static int omap_gpio_probe(struct platform_device *pdev)
>  	ret = pm_runtime_resume_and_get(dev);
>  	if (ret < 0) {
>  		pm_runtime_disable(dev);
> -		if (bank->dbck_flag)
> -			clk_unprepare(bank->dbck);
>  		return ret;
>  	}
>  

-- 
Alexander Sverdlin
Siemens AG
www.siemens.com

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

end of thread, other threads:[~2026-11-24  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  8:52 [PATCH] gpio: omap: do not unprepare the debounce clock twice on probe failure Cong Nguyen
2026-11-24  9:30 ` Andreas Kemnade
2026-11-24  9:33 ` Sverdlin, Alexander

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