Linux Remote Processor Subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper
@ 2024-12-02 21:29 Andrew Davis
  2024-12-02 21:29 ` [PATCH v2 2/3] remoteproc: da8xx: Use devm action to release reserved memory Andrew Davis
  2024-12-02 21:29 ` [PATCH v2 3/3] remoteproc: da8xx: Use devm_rproc_add() helper Andrew Davis
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Davis @ 2024-12-02 21:29 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier
  Cc: linux-remoteproc, linux-kernel, Andrew Davis

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/da8xx_remoteproc.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
index 93031f0867d10..47df21bea5254 100644
--- a/drivers/remoteproc/da8xx_remoteproc.c
+++ b/drivers/remoteproc/da8xx_remoteproc.c
@@ -276,8 +276,8 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
 			return dev_err_probe(dev, ret, "device does not have specific CMA pool\n");
 	}
 
-	rproc = rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
-		sizeof(*drproc));
+	rproc = devm_rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
+				 sizeof(*drproc));
 	if (!rproc) {
 		ret = -ENOMEM;
 		goto free_mem;
@@ -294,7 +294,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
 
 	ret = da8xx_rproc_get_internal_memories(pdev, drproc);
 	if (ret)
-		goto free_rproc;
+		goto free_mem;
 
 	platform_set_drvdata(pdev, rproc);
 
@@ -304,7 +304,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
 					rproc);
 	if (ret) {
 		dev_err(dev, "devm_request_threaded_irq error: %d\n", ret);
-		goto free_rproc;
+		goto free_mem;
 	}
 
 	/*
@@ -314,7 +314,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
 	 */
 	ret = reset_control_assert(dsp_reset);
 	if (ret)
-		goto free_rproc;
+		goto free_mem;
 
 	drproc->chipsig = chipsig;
 	drproc->bootreg = bootreg;
@@ -325,13 +325,11 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
 	ret = rproc_add(rproc);
 	if (ret) {
 		dev_err(dev, "rproc_add failed: %d\n", ret);
-		goto free_rproc;
+		goto free_mem;
 	}
 
 	return 0;
 
-free_rproc:
-	rproc_free(rproc);
 free_mem:
 	if (dev->of_node)
 		of_reserved_mem_device_release(dev);
@@ -352,7 +350,6 @@ static void da8xx_rproc_remove(struct platform_device *pdev)
 	disable_irq(drproc->irq);
 
 	rproc_del(rproc);
-	rproc_free(rproc);
 	if (dev->of_node)
 		of_reserved_mem_device_release(dev);
 }
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-02 21:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-02 21:29 [PATCH v2 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper Andrew Davis
2024-12-02 21:29 ` [PATCH v2 2/3] remoteproc: da8xx: Use devm action to release reserved memory Andrew Davis
2024-12-02 21:29 ` [PATCH v2 3/3] remoteproc: da8xx: Use devm_rproc_add() helper Andrew Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox