[PATCH v3] dmaengine: dw: Use devm_clk_get_optional_enabled() in dw_probe()

Markus Elfring posted 1 patch 4 days, 4 hours ago
drivers/dma/dw/platform.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
[PATCH v3] dmaengine: dw: Use devm_clk_get_optional_enabled() in dw_probe()
Posted by Markus Elfring 4 days, 4 hours ago
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 21 Nov 2026 09:16:47 +0100

Reuse existing functionality from devm_clk_get_optional_enabled()
instead of keeping duplicate source code.
Clean up disable_unprepare() at error handling path and dw_remove().

This issue was detected by using the Coccinelle software.

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

V3:
Frank Li preferred another wording variation for the change description.

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

diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index 7e76391475ac..13c44ee5e047 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -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
Re: [PATCH v3] dmaengine: dw: Use devm_clk_get_optional_enabled() in dw_probe()
Posted by Frank Li 17 hours ago
On Sat, Nov 21, 2026 at 09:32:49AM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 21 Nov 2026 09:16:47 +0100
>
> Reuse existing functionality from devm_clk_get_optional_enabled()
> instead of keeping duplicate source code.
> Clean up disable_unprepare() at error handling path and dw_remove().
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>
> V3:
> Frank Li preferred another wording variation for the change description.
>
> 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(-)
>
> diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
> index 7e76391475ac..13c44ee5e047 100644
> --- a/drivers/dma/dw/platform.c
> +++ b/drivers/dma/dw/platform.c
> @@ -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
>
Re: [PATCH v3] dmaengine: dw: Use devm_clk_get_optional_enabled() in dw_probe()
Posted by Andy Shevchenko 2 days, 4 hours ago
On Sat, Nov 21, 2026 at 09:32:49AM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 21 Nov 2026 09:16:47 +0100

Frank, FYI, the above From: header is one of the correct approaches to submit
the author. The Date: one is not wrong either (`git am` should swallow it).

> Reuse existing functionality from devm_clk_get_optional_enabled()
> instead of keeping duplicate source code.
> Clean up disable_unprepare() at error handling path and dw_remove().
> 
> This issue was detected by using the Coccinelle software.

-- 
With Best Regards,
Andy Shevchenko