diff options
| author | Andrew Davis <afd@ti.com> | 2025-08-14 10:39:38 -0500 |
|---|---|---|
| committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2025-08-26 09:40:29 -0600 |
| commit | 642f8c01e31dd2918e9e655f29846326bf7fad4c (patch) | |
| tree | e6821f95534aa80a129e961ff81ba388f28bb841 | |
| parent | 461edcf73eec57bc0006fbb5209f5012c514c58b (diff) | |
remoteproc: wkup_m3: Use devm action to call PM runtime put sync
This helps prevent mistakes like putting out of order in cleanup functions
and forgetting to put sync on error paths.
Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20250814153940.670564-2-afd@ti.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
| -rw-r--r-- | drivers/remoteproc/wkup_m3_rproc.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c index 35c2145b12db..2569f041d9ca 100644 --- a/drivers/remoteproc/wkup_m3_rproc.c +++ b/drivers/remoteproc/wkup_m3_rproc.c @@ -125,6 +125,13 @@ static const struct of_device_id wkup_m3_rproc_of_match[] = { }; MODULE_DEVICE_TABLE(of, wkup_m3_rproc_of_match); +static void wkup_m3_rproc_pm_runtime_put(void *data) +{ + struct device *dev = data; + + pm_runtime_put_sync(dev); +} + static int wkup_m3_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -152,17 +159,16 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) if (ret < 0) return dev_err_probe(dev, ret, "Failed to enable runtime PM\n"); ret = pm_runtime_get_sync(&pdev->dev); - if (ret < 0) { - dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n"); - goto err; - } + if (ret < 0) + return dev_err_probe(dev, ret, "pm_runtime_get_sync() failed\n"); + ret = devm_add_action_or_reset(dev, wkup_m3_rproc_pm_runtime_put, dev); + 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)); - if (!rproc) { - ret = -ENOMEM; - goto err; - } + if (!rproc) + return -ENOMEM; rproc->auto_boot = false; rproc->sysfs_read_only = true; @@ -219,8 +225,6 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) err_put_rproc: rproc_free(rproc); -err: - pm_runtime_put_noidle(dev); return ret; } @@ -230,7 +234,6 @@ static void wkup_m3_rproc_remove(struct platform_device *pdev) rproc_del(rproc); rproc_free(rproc); - pm_runtime_put_sync(&pdev->dev); } #ifdef CONFIG_PM |
