diff mbox series

[-next] bus: imx-weim: Use devm_clk_get_enabled() helper function

Message ID 20230825071913.2807800-1-ruanjinjie@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] bus: imx-weim: Use devm_clk_get_enabled() helper function | expand

Commit Message

Jinjie Ruan Aug. 25, 2023, 7:19 a.m. UTC
The devm_clk_get_enabled() helper:
    - calls devm_clk_get()
    - calls clk_prepare_enable() and registers what is needed in order to
      call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/bus/imx-weim.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
index 42c9386a7b42..5d48dd3d9f92 100644
--- a/drivers/bus/imx-weim.c
+++ b/drivers/bus/imx-weim.c
@@ -280,20 +280,14 @@  static int weim_probe(struct platform_device *pdev)
 	priv->base = base;
 	dev_set_drvdata(&pdev->dev, priv);
 
-	/* get the clock */
-	clk = devm_clk_get(&pdev->dev, NULL);
+	/* get and enable the clock */
+	clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	ret = clk_prepare_enable(clk);
-	if (ret)
-		return ret;
-
 	/* parse the device node */
 	ret = weim_parse_dt(pdev);
-	if (ret)
-		clk_disable_unprepare(clk);
-	else
+	if (!ret)
 		dev_info(&pdev->dev, "Driver registered.\n");
 
 	return ret;