All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] usb: bdc: Use devm_clk_get_optional_enabled() in bdc_probe()
@ 2026-11-21 15:00 Markus Elfring
  2026-11-21 15:05 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-11-21 15:00 UTC (permalink / raw)
  To: linux-usb, bcm-kernel-feedback-list, Al Cooper,
	Christophe Jaillet, Greg Kroah-Hartman, Justin Chen, Neill Kapron
  Cc: LKML, kernel-janitors, Andy Shevchenko, Florian Fainelli,
	Frank Li

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


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

* Re: [PATCH v2] usb: bdc: Use devm_clk_get_optional_enabled() in bdc_probe()
  2026-11-21 15:00 [PATCH v2] usb: bdc: Use devm_clk_get_optional_enabled() in bdc_probe() Markus Elfring
@ 2026-11-21 15:05 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-21 15:05 UTC (permalink / raw)
  To: Markus Elfring, linux-usb

> 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>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cc916c01-fb49-43ae-ac08-047f5fc5001e@web.de?part=1

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

end of thread, other threads:[~2026-11-21 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21 15:00 [PATCH v2] usb: bdc: Use devm_clk_get_optional_enabled() in bdc_probe() Markus Elfring
2026-11-21 15:05 ` sashiko-bot

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.