Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: Andreas Kemnade <andreas@kemnade.info>
To: Jiawen Liu <1298662399@qq.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	Kevin Hilman <khilman@kernel.org>,
	Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpio: omap: handle clk_prepare failure in probe
Date: Thu, 20 Aug 2026 14:25:47 +0200	[thread overview]
Message-ID: <20260820142547.63b85ca3@kemnade.info> (raw)
In-Reply-To: <tencent_B4F504456790E8BA3C4EAB80F4BFB6954E08@qq.com>

On Tue, 18 Aug 2026 17:08:54 +0400
Jiawen Liu <1298662399@qq.com> wrote:

> omap_gpio_probe() ignores the return value of clk_prepare(bank->dbck).
> If clk_prepare fails, the clock is not prepared, but bank->dbck_flag
> remains true. Later, omap_gpio_remove() or the probe error path calls
> clk_unprepare(bank->dbck) unconditionally when dbck_flag is true,
> leading to an unbalanced clock operation.
> 
> Check the return value of clk_prepare in omap_gpio_probe. On failure,
> clear dbck_flag and return the error, preventing unbalanced
> clk_unprepare in remove or error paths.
> 
> Signed-off-by: jiawen <1298662399@qq.com>
> ---
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1462,7 +1462,12 @@
>  				"Could not get gpio dbck. Disable debounce\n");
>  			bank->dbck_flag = false;
>  		} else {
> -			clk_prepare(bank->dbck);
> +			ret = clk_prepare(bank->dbck);
> +			if (ret) {
> +				dev_err(dev, "Could not prepare gpio dbck\n");
> +				bank->dbck_flag = false;
> +				return ret;
> +			}
>
What about simply using devm_clk_get_prepared() here? That would simplify
things a lot, given that AFAIK,  prepare is a no-op here anyways.

Regards,
Andreas

      parent reply	other threads:[~2026-08-20 12:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 13:08 [PATCH] gpio: omap: handle clk_prepare failure in probe Jiawen Liu
2026-08-20  9:19 ` Markus Elfring
2026-08-20  9:48   ` Andreas Kemnade
2026-08-20 10:47     ` Markus Elfring
2026-08-20 13:43       ` Andreas Kemnade
2026-08-20 12:25 ` Andreas Kemnade [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260820142547.63b85ca3@kemnade.info \
    --to=andreas@kemnade.info \
    --cc=1298662399@qq.com \
    --cc=brgl@kernel.org \
    --cc=grygorii.strashko@ti.com \
    --cc=khilman@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=ssantosh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox