diff options
author | Andrew Davis <afd@ti.com> | 2024-06-10 17:17:17 +0200 |
---|---|---|
committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2024-06-13 18:05:11 +0200 |
commit | 5efcc364fc63750fee93e5791130a1658b5061e8 (patch) | |
tree | f2a7fb0bb12127176e2412beb8bc05a86e6c58a5 /drivers/remoteproc | |
parent | remoteproc: omap: Use devm_rproc_alloc() helper (diff) | |
download | linux-5efcc364fc63750fee93e5791130a1658b5061e8.tar.xz linux-5efcc364fc63750fee93e5791130a1658b5061e8.zip |
remoteproc: omap: Use devm action to release reserved memory
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>
Link: https://lore.kernel.org/r/20240610151721.189472-2-afd@ti.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r-- | drivers/remoteproc/omap_remoteproc.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index e91e01658380..df46be84658f 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -1277,6 +1277,13 @@ static int omap_rproc_of_get_timers(struct platform_device *pdev, return 0; } +static void omap_rproc_mem_release(void *data) +{ + struct device *dev = data; + + of_reserved_mem_device_release(dev); +} + static int omap_rproc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1346,19 +1353,17 @@ static int omap_rproc_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "Typically this should be provided,\n"); dev_warn(&pdev->dev, "only omit if you know what you are doing.\n"); } + ret = devm_add_action_or_reset(&pdev->dev, omap_rproc_mem_release, &pdev->dev); + if (ret) + return ret; platform_set_drvdata(pdev, rproc); ret = rproc_add(rproc); if (ret) - goto release_mem; + return ret; return 0; - -release_mem: - of_reserved_mem_device_release(&pdev->dev); - - return ret; } static void omap_rproc_remove(struct platform_device *pdev) @@ -1366,7 +1371,6 @@ static void omap_rproc_remove(struct platform_device *pdev) struct rproc *rproc = platform_get_drvdata(pdev); rproc_del(rproc); - of_reserved_mem_device_release(&pdev->dev); } static const struct dev_pm_ops omap_rproc_pm_ops = { |