mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
remoteproc: imx_rproc: Use devm_clk_get_enabled() and simplify cleanup
Replace separate calls to devm_clk_get() and clk_prepare_enable() with devm_clk_get_enabled(), which combines clock acquisition and enabling into a single managed step. Simplify the probe logic and remove the need for manual clock disable in error and remove paths. Also, update error handling to eliminate redundant cleanup steps and use return-based error propagation where appropriate. Improve code clarity and reduce the chance of resource leaks or incorrect ordering in cleanup paths. No functional changes. Reviewed-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com> Link: https://lore.kernel.org/r/20250926-imx_rproc_v3-v3-4-4c0ec279cc5f@nxp.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
This commit is contained in:
committed by
Mathieu Poirier
parent
b0106defc0
commit
65af722aa8
@@ -1006,26 +1006,19 @@ static int imx_rproc_clk_enable(struct imx_rproc *priv)
|
||||
{
|
||||
const struct imx_rproc_dcfg *dcfg = priv->dcfg;
|
||||
struct device *dev = priv->dev;
|
||||
int ret;
|
||||
|
||||
/* Remote core is not under control of Linux or it is managed by SCU API */
|
||||
if (dcfg->method == IMX_RPROC_NONE || dcfg->method == IMX_RPROC_SCU_API)
|
||||
return 0;
|
||||
|
||||
priv->clk = devm_clk_get(dev, NULL);
|
||||
if (IS_ERR(priv->clk)) {
|
||||
dev_err(dev, "Failed to get clock\n");
|
||||
return PTR_ERR(priv->clk);
|
||||
}
|
||||
|
||||
/*
|
||||
* clk for M4 block including memory. Should be
|
||||
* enabled before .start for FW transfer.
|
||||
*/
|
||||
ret = clk_prepare_enable(priv->clk);
|
||||
if (ret) {
|
||||
priv->clk = devm_clk_get_enabled(dev, NULL);
|
||||
if (IS_ERR(priv->clk)) {
|
||||
dev_err(dev, "Failed to enable clock\n");
|
||||
return ret;
|
||||
return PTR_ERR(priv->clk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1127,7 +1120,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
|
||||
imx_rproc_sys_off_handler, rproc);
|
||||
if (ret) {
|
||||
dev_err(dev, "register power off handler failure\n");
|
||||
goto err_put_clk;
|
||||
goto err_put_scu;
|
||||
}
|
||||
|
||||
ret = devm_register_sys_off_handler(dev, SYS_OFF_MODE_RESTART_PREPARE,
|
||||
@@ -1135,7 +1128,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
|
||||
imx_rproc_sys_off_handler, rproc);
|
||||
if (ret) {
|
||||
dev_err(dev, "register restart handler failure\n");
|
||||
goto err_put_clk;
|
||||
goto err_put_scu;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1144,7 +1137,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
|
||||
ret = pm_runtime_resume_and_get(dev);
|
||||
if (ret) {
|
||||
dev_err(dev, "pm_runtime get failed: %d\n", ret);
|
||||
goto err_put_clk;
|
||||
goto err_put_scu;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,8 +1154,6 @@ err_put_pm:
|
||||
pm_runtime_disable(dev);
|
||||
pm_runtime_put_noidle(dev);
|
||||
}
|
||||
err_put_clk:
|
||||
clk_disable_unprepare(priv->clk);
|
||||
err_put_scu:
|
||||
imx_rproc_put_scu(rproc);
|
||||
|
||||
@@ -1178,7 +1169,6 @@ static void imx_rproc_remove(struct platform_device *pdev)
|
||||
pm_runtime_disable(priv->dev);
|
||||
pm_runtime_put_noidle(priv->dev);
|
||||
}
|
||||
clk_disable_unprepare(priv->clk);
|
||||
rproc_del(rproc);
|
||||
imx_rproc_put_scu(rproc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user