From: sashiko-bot@kernel.org
To: "Markus Elfring" <Markus.Elfring@web.de>, linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: chipidea: Use devm_clk_get_optional_enabled() in two probe functions
Date: Thu, 19 Nov 2026 18:50:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-223804@kernel.org> (raw)
In-Reply-To: <6d2450cf-9bbc-47b6-9ea3-f91bc1b91371@web.de>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] usb: chipidea: npcm: double clk_disable_unprepare() on probe
err and remove
- [High] usb: chipidea: usb2: double clk_disable_unprepare() on probe
err and remove
--
commit f08588246bb9a1d0ba3a56c799e77b7dacaf4937
Author: Markus Elfring <elfring@users.sourceforge.net>
usb: chipidea: Use devm_clk_get_optional_enabled() in two probe functions
This commit replaces devm_clk_get_optional() and clk_prepare_enable() with
devm_clk_get_optional_enabled() in npcm_udc_probe() and ci_hdrc_usb2_probe().
> diff --git a/drivers/usb/chipidea/ci_hdrc_npcm.c b/drivers/usb/chipidea/ci_hdrc_npcm.c
> index 75a0223b578a8..5052287f69c2a 100644
> --- a/drivers/usb/chipidea/ci_hdrc_npcm.c
> +++ b/drivers/usb/chipidea/ci_hdrc_npcm.c
> @@ -47,14 +47,10 @@ static int npcm_udc_probe(struct platform_device *pdev)
> return -ENOMEM;
> platform_set_drvdata(pdev, ci);
>
> - ci->core_clk = devm_clk_get_optional(dev, NULL);
> + ci->core_clk = devm_clk_get_optional_enabled(dev, NULL);
> if (IS_ERR(ci->core_clk))
> return PTR_ERR(ci->core_clk);
>
> - ret = clk_prepare_enable(ci->core_clk);
> - if (ret)
> - return dev_err_probe(dev, ret, "failed to enable the clock: %d\n", ret);
> -
> ci->pdata.name = dev_name(dev);
> ci->pdata.capoffset = DEF_CAPOFFSET;
> ci->pdata.flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
[Severity: High]
Does this cause clk_disable_unprepare(ci->core_clk) to run twice when
ci_hdrc_add_device() fails or when the device is removed?
devm_clk_get_optional_enabled() registers a devres action to disable and
unprepare ci->core_clk automatically, but both the clk_err error path in
npcm_udc_probe() and npcm_udc_remove() still call
clk_disable_unprepare(ci->core_clk) manually, underflowing the clock's
enable and prepare counts.
> diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
> index b0200c5937cd5..d33ab6873defb 100644
> --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
> +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> @@ -70,16 +70,10 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
> if (!priv)
> return -ENOMEM;
>
> - priv->clk = devm_clk_get_optional(dev, NULL);
> + priv->clk = devm_clk_get_optional_enabled(dev, NULL);
> if (IS_ERR(priv->clk))
> return PTR_ERR(priv->clk);
>
> - ret = clk_prepare_enable(priv->clk);
> - if (ret) {
> - dev_err(dev, "failed to enable the clock: %d\n", ret);
> - return ret;
> - }
> -
> ci_pdata->name = dev_name(dev);
>
> priv->ci_pdev = ci_hdrc_add_device(dev, pdev->resource,
[Severity: High]
Similarly, won't priv->clk be disabled and unprepared twice if
ci_hdrc_add_device() fails (or returns -EPROBE_DEFER) or when
ci_hdrc_usb2_remove() runs?
The clk_err path in ci_hdrc_usb2_probe() and ci_hdrc_usb2_remove() still
call clk_disable_unprepare(priv->clk) before devres cleanup calls it a
second time.
--
Sashiko AI review · https://sashiko.dev/#/patchset/6d2450cf-9bbc-47b6-9ea3-f91bc1b91371@web.de?part=1
prev parent reply other threads:[~2026-11-19 18:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 18:43 [PATCH] usb: chipidea: Use devm_clk_get_optional_enabled() in two probe functions Markus Elfring
2026-11-19 18:50 ` sashiko-bot [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=sashiko-outbox-223804@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Markus.Elfring@web.de \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.