From: Andrew Davis <afd@ti.com>
To: Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: <linux-remoteproc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Andrew Davis <afd@ti.com>
Subject: [PATCH 3/4] remoteproc: wkup_m3: Use devm_rproc_alloc() helper
Date: Mon, 2 Dec 2024 16:19:03 -0600 [thread overview]
Message-ID: <20241202221904.319149-3-afd@ti.com> (raw)
In-Reply-To: <20241202221904.319149-1-afd@ti.com>
Use the device lifecycle managed allocation function. This helps prevent
mistakes like freeing out of order in cleanup functions and forgetting to
free on error paths.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/remoteproc/wkup_m3_rproc.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c
index 2569f041d9cab..30e9ecd75657f 100644
--- a/drivers/remoteproc/wkup_m3_rproc.c
+++ b/drivers/remoteproc/wkup_m3_rproc.c
@@ -165,8 +165,8 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret, "failed to add disable pm devm action\n");
- rproc = rproc_alloc(dev, "wkup_m3", &wkup_m3_rproc_ops,
- fw_name, sizeof(*wkupm3));
+ rproc = devm_rproc_alloc(dev, "wkup_m3", &wkup_m3_rproc_ops,
+ fw_name, sizeof(*wkupm3));
if (!rproc)
return -ENOMEM;
@@ -183,9 +183,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
if (!wkupm3->rsts) {
if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
pdata->reset_name)) {
- dev_err(dev, "Platform data missing!\n");
- ret = -ENODEV;
- goto err_put_rproc;
+ return dev_err_probe(dev, -ENODEV, "Platform data missing!\n");
}
}
@@ -193,12 +191,9 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
mem_names[i]);
wkupm3->mem[i].cpu_addr = devm_ioremap_resource(dev, res);
- if (IS_ERR(wkupm3->mem[i].cpu_addr)) {
- dev_err(&pdev->dev, "devm_ioremap_resource failed for resource %d\n",
- i);
- ret = PTR_ERR(wkupm3->mem[i].cpu_addr);
- goto err_put_rproc;
- }
+ if (IS_ERR(wkupm3->mem[i].cpu_addr))
+ return dev_err_probe(dev, PTR_ERR(wkupm3->mem[i].cpu_addr),
+ "devm_ioremap_resource failed for resource %d\n", i);
wkupm3->mem[i].bus_addr = res->start;
wkupm3->mem[i].size = resource_size(res);
addrp = of_get_address(dev->of_node, i, &size, NULL);
@@ -216,16 +211,10 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
dev_set_drvdata(dev, rproc);
ret = rproc_add(rproc);
- if (ret) {
- dev_err(dev, "rproc_add failed\n");
- goto err_put_rproc;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "rproc_add failed\n");
return 0;
-
-err_put_rproc:
- rproc_free(rproc);
- return ret;
}
static void wkup_m3_rproc_remove(struct platform_device *pdev)
@@ -233,7 +222,6 @@ static void wkup_m3_rproc_remove(struct platform_device *pdev)
struct rproc *rproc = platform_get_drvdata(pdev);
rproc_del(rproc);
- rproc_free(rproc);
}
#ifdef CONFIG_PM
--
2.39.2
next prev parent reply other threads:[~2024-12-02 22:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 22:19 [PATCH 1/4] remoteproc: wkup_m3: Use devm_pm_runtime_enable() helper Andrew Davis
2024-12-02 22:19 ` [PATCH 2/4] remoteproc: wkup_m3: Use devm action to call PM runtime put sync Andrew Davis
2024-12-02 22:19 ` Andrew Davis [this message]
2024-12-02 22:19 ` [PATCH 4/4] remoteproc: wkup_m3: Use devm_rproc_add() helper Andrew Davis
-- strict thread matches above, loose matches on Subject: below --
2025-08-14 15:39 [PATCH 1/4] remoteproc: wkup_m3: Use devm_pm_runtime_enable() helper Andrew Davis
2025-08-14 15:39 ` [PATCH 3/4] remoteproc: wkup_m3: Use devm_rproc_alloc() helper Andrew Davis
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=20241202221904.319149-3-afd@ti.com \
--to=afd@ti.com \
--cc=andersson@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@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