usb: chipidea: Use devm_clk_get_optional_enabled() in two probe functions
Subsystems (4)
PATCH v2 1/1 usb: chipidea: Use devm_clk_get_optional_enabled() in two probe functions
From: Markus Elfring <[email protected]>
Date: Sat, 21 Nov 2026 17:06:32 +0100
* Reuse existing functionality from devm_clk_get_optional_enabled() instead of keeping duplicate source code.
* Omit a clk_disable_unprepare() call on error handling paths and in the implementation of two remove functions.
* Delete the label “clk_err”.
This issue was detected by using the Coccinelle software.
---
V2:
Sashiko provided hints for further development considerations.
https://sashiko.dev/#/patchset/6d2450cf-9bbc-47b6-9ea3-f91bc1b91371%40web.de
drivers/usb/chipidea/ci_hdrc_npcm.c | 13 ++----------- drivers/usb/chipidea/ci_hdrc_usb2.c | 15 ++------------- 2 files changed, 4 insertions(+), 24 deletions(-)
drivers/usb/chipidea/ci_hdrc_npcm.c +2 -11
@@ -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 |
@@ -67,17 +63,13 @@ static int npcm_udc_probe(struct platform_device *pdev)if (IS_ERR (plat_ci)) { ret =PTR_ERR (plat_ci);dev_err (dev,"failed to register HDRC NPCM device: %d\n" , ret); - goto clk_err; +return ret; }pm_runtime_no_callbacks (dev);pm_runtime_enable (dev);return 0 ; - -clk_err: -clk_disable_unprepare (ci->core_clk); -return ret; }static void npcm_udc_remove (struct platform_device *pdev)
@@ -86,7 +78,6 @@ static void npcm_udc_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev);ci_hdrc_remove_device (ci->ci); -clk_disable_unprepare (ci->core_clk); }static const struct of_device_id npcm_udc_dt_match[] = {
drivers/usb/chipidea/ci_hdrc_usb2.c +2 -13
@@ -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,
@@ -90,7 +84,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)dev_err (dev,"failed to register ci_hdrc platform device: %d\n" , ret); - goto clk_err; +return ret; }platform_set_drvdata (pdev, priv);
@@ -99,10 +93,6 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)pm_runtime_enable (dev);return 0 ; - -clk_err: -clk_disable_unprepare (priv->clk); -return ret; }static void ci_hdrc_usb2_remove (struct platform_device *pdev)
@@ -111,7 +101,6 @@ static void ci_hdrc_usb2_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev);ci_hdrc_remove_device (priv->ci_pdev); -clk_disable_unprepare (priv->clk); }static struct platform_driver ci_hdrc_usb2_driver = {
Signature · 1 line
2.56.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 6 lines
From: Markus Elfring <[email protected]>
Date: Sat, 21 Nov 2026 17:06:32 +0100* Reuse existing functionality from
devm_clk_get_optional_enabled()instead of keeping duplicate source code.
Quoted 8 lines
* Omit a
clk_disable_unprepare()call on error handling paths and in the implementation of two remove functions.* Delete the label “clk_err”.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1