Skip to contentSkip to conversation

dmaengine: dw: Use devm_clk_get_optional_enabled() in dw_probe()

PATCH In review Markus Elfring 2 participants 3 messages Nov 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dmaengine: dw: Use devm_clk_get_optional_enabled() in dw_probe()

From: Markus Elfring <[email protected]>
Date: Fri, 20 Nov 2026 14:23:13 +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 “dw_remove”.

This issue was detected by using the Coccinelle software.

---

V2:
Andy Shevchenko and Frank Li requested further adjustments according to the proposed changes.

 drivers/dma/dw/platform.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/dma/dw/platform.c +1 -6
index 7e76391475ac..13c44ee5e047 100644
@@ -64,12 +64,9 @@ static int dw_probe(struct platform_device *pdev)
 
 	data->chip = chip;
 
-	chip->clk = devm_clk_get_optional(chip->dev, "hclk");
+	chip->clk = devm_clk_get_optional_enabled(chip->dev, "hclk");
 	if (IS_ERR(chip->clk))
 		return PTR_ERR(chip->clk);
-	ret = clk_prepare_enable(chip->clk);
-	if (ret)
-		return ret;
 
 	pm_runtime_enable(&pdev->dev);
 
@@ -87,7 +84,6 @@ static int dw_probe(struct platform_device *pdev)
 
 err_dw_dma_probe:
 	pm_runtime_disable(&pdev->dev);
-	clk_disable_unprepare(chip->clk);
 	return ret;
 }
 
@@ -106,7 +102,6 @@ static void dw_remove(struct platform_device *pdev)
 		dev_warn(chip->dev, "can't remove device properly: %d\n", ret);
 
 	pm_runtime_disable(&pdev->dev);
-	clk_disable_unprepare(chip->clk);
 }
 
 static void dw_shutdown(struct platform_device *pdev)
Signature · 1 line
2.56.1
#1 lore raw
Quoted 2 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 20 Nov 2026 14:23:13 +0100

Any tools issue ? your patch look strange. Why this information at body

Quoted 3 lines

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

Needn't *

Quoted 3 lines

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

Clean up disable_unprepare() at error handling patch and dw_remove()

Frank

Quoted 51 lines

This issue was detected by using the Coccinelle software.

---

V2:
Andy Shevchenko and Frank Li requested further adjustments according to the proposed changes.

 drivers/dma/dw/platform.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/dma/dw/platform.c +1 -7
index 7e76391475ac..13c44ee5e047 100644
@@ -64,12 +64,9 @@ static int dw_probe(struct platform_device *pdev)
 
 	data->chip = chip;
 
-	chip->clk = devm_clk_get_optional(chip->dev, "hclk");
+	chip->clk = devm_clk_get_optional_enabled(chip->dev, "hclk");
 	if (IS_ERR(chip->clk))
 		return PTR_ERR(chip->clk);
-	ret = clk_prepare_enable(chip->clk);
-	if (ret)
-		return ret;
 
 	pm_runtime_enable(&pdev->dev);
 
@@ -87,7 +84,6 @@ static int dw_probe(struct platform_device *pdev)
 
 err_dw_dma_probe:
 	pm_runtime_disable(&pdev->dev);
-	clk_disable_unprepare(chip->clk);
 	return ret;
 }
 
@@ -106,7 +102,6 @@ static void dw_remove(struct platform_device *pdev)
 		dev_warn(chip->dev, "can't remove device properly: %d\n", ret);
 
 	pm_runtime_disable(&pdev->dev);
-	clk_disable_unprepare(chip->clk);
 }
 
 static void dw_shutdown(struct platform_device *pdev)
--

2.56.1

#2 lore raw
Quoted 4 lines
Quoted 2 lines

From: Markus Elfring <[email protected]>
Date: Fri, 20 Nov 2026 14:23:13 +0100

Any tools issue ? your patch look strange. Why this information at body

I am trying to provide some author information.

Regards,
Markus