Skip to content

Commit 642f8c0

Browse files
glneomathieupoirier
authored andcommitted
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>
1 parent 461edcf commit 642f8c0

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

drivers/remoteproc/wkup_m3_rproc.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ static const struct of_device_id wkup_m3_rproc_of_match[] = {
125125
};
126126
MODULE_DEVICE_TABLE(of, wkup_m3_rproc_of_match);
127127

128+
static void wkup_m3_rproc_pm_runtime_put(void *data)
129+
{
130+
struct device *dev = data;
131+
132+
pm_runtime_put_sync(dev);
133+
}
134+
128135
static int wkup_m3_rproc_probe(struct platform_device *pdev)
129136
{
130137
struct device *dev = &pdev->dev;
@@ -152,17 +159,16 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
152159
if (ret < 0)
153160
return dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
154161
ret = pm_runtime_get_sync(&pdev->dev);
155-
if (ret < 0) {
156-
dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n");
157-
goto err;
158-
}
162+
if (ret < 0)
163+
return dev_err_probe(dev, ret, "pm_runtime_get_sync() failed\n");
164+
ret = devm_add_action_or_reset(dev, wkup_m3_rproc_pm_runtime_put, dev);
165+
if (ret)
166+
return dev_err_probe(dev, ret, "failed to add disable pm devm action\n");
159167

160168
rproc = rproc_alloc(dev, "wkup_m3", &wkup_m3_rproc_ops,
161169
fw_name, sizeof(*wkupm3));
162-
if (!rproc) {
163-
ret = -ENOMEM;
164-
goto err;
165-
}
170+
if (!rproc)
171+
return -ENOMEM;
166172

167173
rproc->auto_boot = false;
168174
rproc->sysfs_read_only = true;
@@ -219,8 +225,6 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
219225

220226
err_put_rproc:
221227
rproc_free(rproc);
222-
err:
223-
pm_runtime_put_noidle(dev);
224228
return ret;
225229
}
226230

@@ -230,7 +234,6 @@ static void wkup_m3_rproc_remove(struct platform_device *pdev)
230234

231235
rproc_del(rproc);
232236
rproc_free(rproc);
233-
pm_runtime_put_sync(&pdev->dev);
234237
}
235238

236239
#ifdef CONFIG_PM

0 commit comments

Comments
 (0)