mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-12 01:20:14 +00:00
remoteproc: imx_rproc: Use devm_add_action_or_reset() for mailbox cleanup
Convert imx_rproc_free_mbox() to a devm-managed cleanup action using devm_add_action_or_reset(). Ensure the mailbox resources are freed automatically with the device lifecycle, simplify error handling and removing the need for manual cleanup in probe and remove paths. Also improve error reporting by using dev_err_probe() for consistency and clarity. 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-3-4c0ec279cc5f@nxp.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
This commit is contained in:
parent
6c5c37dc41
commit
b0106defc0
@ -93,7 +93,7 @@ struct imx_rproc_mem {
|
||||
#define ATT_CORE(I) BIT((I))
|
||||
|
||||
static int imx_rproc_xtr_mbox_init(struct rproc *rproc, bool tx_block);
|
||||
static void imx_rproc_free_mbox(struct rproc *rproc);
|
||||
static void imx_rproc_free_mbox(void *data);
|
||||
|
||||
struct imx_rproc {
|
||||
struct device *dev;
|
||||
@ -780,8 +780,9 @@ static int imx_rproc_xtr_mbox_init(struct rproc *rproc, bool tx_block)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void imx_rproc_free_mbox(struct rproc *rproc)
|
||||
static void imx_rproc_free_mbox(void *data)
|
||||
{
|
||||
struct rproc *rproc = data;
|
||||
struct imx_rproc *priv = rproc->priv;
|
||||
|
||||
if (priv->tx_ch) {
|
||||
@ -1094,15 +1095,18 @@ static int imx_rproc_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_add_action_or_reset(dev, imx_rproc_free_mbox, rproc);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret,
|
||||
"Failed to add devm free mbox action: %d\n", ret);
|
||||
|
||||
ret = imx_rproc_addr_init(priv, pdev);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed on imx_rproc_addr_init\n");
|
||||
goto err_put_mbox;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed on imx_rproc_addr_init\n");
|
||||
|
||||
ret = imx_rproc_detect_mode(priv);
|
||||
if (ret)
|
||||
goto err_put_mbox;
|
||||
return dev_err_probe(dev, ret, "failed on detect mode\n");
|
||||
|
||||
ret = imx_rproc_clk_enable(priv);
|
||||
if (ret)
|
||||
@ -1161,8 +1165,6 @@ err_put_clk:
|
||||
clk_disable_unprepare(priv->clk);
|
||||
err_put_scu:
|
||||
imx_rproc_put_scu(rproc);
|
||||
err_put_mbox:
|
||||
imx_rproc_free_mbox(rproc);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1179,7 +1181,6 @@ static void imx_rproc_remove(struct platform_device *pdev)
|
||||
clk_disable_unprepare(priv->clk);
|
||||
rproc_del(rproc);
|
||||
imx_rproc_put_scu(rproc);
|
||||
imx_rproc_free_mbox(rproc);
|
||||
}
|
||||
|
||||
static const struct imx_rproc_plat_ops imx_rproc_ops_arm_smc = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user