Re: [PATCH v2] gpio: omap: handle debounce clock preparation failure
From: Sverdlin, Alexander
Date: Tue Nov 10 2026 - 08:32:54 EST
Hi Jiawen,
thank you for the patch!
On Mon, 2026-11-09 at 17:42 +0400, Jiawen Liu wrote:
> omap_gpio_probe() ignores the return value of clk_prepare() for the
> debounce clock. If preparation fails, the driver still treats debounce as
> available and may use or unprepare a clock that was not prepared.
>
> Use devm_clk_get_prepared() and disable debounce if the clock cannot be
> obtained or prepared. This keeps the existing behavior for clock lookup
> failures. Remove both manual clk_unprepare() calls because the managed
> clock is released on probe failure and device removal.
The development history below could probably go below "---" so that
it doesn't appear in git history?
> An earlier managed-clock conversion was dropped after a reported boot
> failure. A follow-up removing the two manual unprepare calls was reported
> to restore boot. This change also removes those calls.
> Built gpio-omap.o with ARM multi_v7_defconfig and Clang 19; the current
> patch has not been tested on OMAP hardware.
>
> The original report was generated using BMC-Agent; source review and
> maintainer feedback informed this revision.
>
> Fixes: 5d9452e7c52a ("gpio: omap: fix clk_prepare/unprepare usage")
> Suggested-by: Andreas Kemnade <andreas@xxxxxxxxxxxx>
> Link: https://lore.kernel.org/r/tencent_B4F504456790E8BA3C4EAB80F4BFB6954E08@xxxxxx
> Link: https://lkml.rescloud.iu.edu/hypermail/linux/kernel/2412.2/00414.html
> Signed-off-by: Jiawen Liu <1298662399@xxxxxx>
other than above,
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@xxxxxxxxxxx>
The patch causes no regression on our AM335x HW deploying gpio-omap driver,
Tested-by: Alexander Sverdlin <alexander.sverdlin@xxxxxxxxxxx>
> ---
> Changes in v2:
> - Use devm_clk_get_prepared() and remove both manual unprepare calls.
> - Disable debounce on prepare failure, retaining clock-get failure behavior.
> - Add the Fixes tag and describe the earlier managed-clock attempt.
>
> Built with ARCH=arm, LLVM=-19, multi_v7_defconfig, W=1 and
> CONFIG_GPIO_OMAP=y. No OMAP hardware test or current reproducer is available.
>
> drivers/gpio/gpio-omap.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index a9734b2a1..314bbb48e 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
--
Alexander Sverdlin
Siemens AG
www.siemens.com