From: Peng Fan <peng.fan@nxp.com>
To: Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Hiago De Franco <hiago.franco@toradex.com>
Cc: linux-remoteproc@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
Frank Li <Frank.Li@nxp.com>,
Daniel Baluta <daniel.baluta@nxp.com>
Subject: [PATCH v2 3/6] remoteproc: imx_rproc: Use devm_add_action_or_reset() for mailbox cleanup
Date: Tue, 23 Sep 2025 13:16:35 +0800 [thread overview]
Message-ID: <20250923-imx_rproc_c2-v2-3-d31c437507e5@nxp.com> (raw)
In-Reply-To: <20250923-imx_rproc_c2-v2-0-d31c437507e5@nxp.com>
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>
---
drivers/remoteproc/imx_rproc.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index cc776f5d75f1f614943c05250877f17537837068..e30b61ee39dacc88f9e938f8c6ffe61fef63dbda 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -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) {
@@ -1101,15 +1102,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)
@@ -1174,8 +1178,6 @@ static int imx_rproc_probe(struct platform_device *pdev)
clk_disable_unprepare(priv->clk);
err_put_scu:
imx_rproc_put_scu(rproc);
-err_put_mbox:
- imx_rproc_free_mbox(rproc);
return ret;
}
@@ -1188,7 +1190,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 = {
--
2.37.1
next prev parent reply other threads:[~2025-09-23 5:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 5:16 [PATCH v2 0/6] remoteproc: imx_rproc: Use device managed API to clean up the driver Peng Fan
2025-09-23 5:16 ` [PATCH v2 1/6] remoteproc: imx_rproc: Fix runtime PM cleanup order and error handling Peng Fan
2025-09-25 10:18 ` Ulf Hansson
2025-09-25 14:24 ` Peng Fan
2025-09-25 13:49 ` Ulf Hansson
2025-09-23 5:16 ` [PATCH v2 2/6] remoteproc: imx_rproc: Use devm_add_action_or_reset() for workqueue cleanup Peng Fan
2025-09-23 5:16 ` Peng Fan [this message]
2025-09-23 5:16 ` [PATCH v2 4/6] remoteproc: imx_rproc: Use devm_clk_get_enabled() and simplify cleanup Peng Fan
2025-09-23 5:16 ` [PATCH v2 5/6] remoteproc: imx_rproc: Use devm_add_action_or_reset() for scu cleanup Peng Fan
2025-09-23 5:16 ` [PATCH v2 6/6] remoteproc: imx_rproc: Use devm_rproc_add() helper Peng Fan
2025-09-24 16:46 ` [PATCH v2 0/6] remoteproc: imx_rproc: Use device managed API to clean up the driver Peng Fan
2025-09-24 17:10 ` Mathieu Poirier
2025-09-24 20:31 ` Peng Fan
2025-09-25 15:25 ` Mathieu Poirier
2025-09-26 8:26 ` Peng Fan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250923-imx_rproc_c2-v2-3-d31c437507e5@nxp.com \
--to=peng.fan@nxp.com \
--cc=Frank.Li@nxp.com \
--cc=andersson@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=festevam@gmail.com \
--cc=hiago.franco@toradex.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®