All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-usb@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com,
	Al Cooper <alcooperx@gmail.com>,
	Christophe Jaillet <christophe.jaillet@wanadoo.fr>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Justin Chen <justin.chen@broadcom.com>,
	Neill Kapron <nkapron@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Frank Li <Frank.Li@kernel.org>
Subject: [PATCH v2] usb: bdc: Use devm_clk_get_optional_enabled() in bdc_probe()
Date: Sat, 21 Nov 2026 16:00:30 +0100	[thread overview]
Message-ID: <cc916c01-fb49-43ae-ac08-047f5fc5001e@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 21 Nov 2026 15:37:14 +0100

* Reuse existing functionality from devm_clk_get_optional_enabled()
  instead of keeping duplicate source code.

* Omit a clk_disable_unprepare() call on an error handling path
  and in the implementation of the function “bdc_remove”.

* Delete the label “disable_clk”.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

V2:
Christophe Jaillet requested further adjustments according to
the proposed changes.


  drivers/usb/gadget/udc/bdc/bdc_core.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 5149c98bf9bf..2369fbc1b70a 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -530,20 +530,14 @@ static int bdc_probe(struct platform_device *pdev)
 		}
 	}
 
-	bdc->clk = devm_clk_get_optional(dev, "sw_usbd");
+	bdc->clk = devm_clk_get_optional_enabled(dev, "sw_usbd");
 	if (IS_ERR(bdc->clk))
 		return PTR_ERR(bdc->clk);
 
-	ret = clk_prepare_enable(bdc->clk);
-	if (ret) {
-		dev_err(dev, "could not enable clock\n");
-		return ret;
-	}
-
 	ret = bdc_phy_init(bdc);
 	if (ret) {
 		dev_err(bdc->dev, "BDC phy init failure:%d\n", ret);
-		goto disable_clk;
+		return ret;
 	}
 
 	temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
@@ -576,8 +570,6 @@ static int bdc_probe(struct platform_device *pdev)
 	bdc_hw_exit(bdc);
 phycleanup:
 	bdc_phy_exit(bdc);
-disable_clk:
-	clk_disable_unprepare(bdc->clk);
 	return ret;
 }
 
@@ -610,7 +602,6 @@ static void bdc_remove(struct platform_device *pdev)
 	bdc_udc_exit(bdc);
 	bdc_hw_exit(bdc);
 	bdc_phy_exit(bdc);
-	clk_disable_unprepare(bdc->clk);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.56.1


             reply	other threads:[~2026-11-21 15:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 15:00 Markus Elfring [this message]
2026-11-21 15:05 ` [PATCH v2] usb: bdc: Use devm_clk_get_optional_enabled() in bdc_probe() sashiko-bot

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=cc916c01-fb49-43ae-ac08-047f5fc5001e@web.de \
    --to=markus.elfring@web.de \
    --cc=Frank.Li@kernel.org \
    --cc=alcooperx@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=justin.chen@broadcom.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nkapron@google.com \
    /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.