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