* [PATCH 1/4] remoteproc: wkup_m3: Use devm_pm_runtime_enable() helper
@ 2024-12-02 22:19 Andrew Davis
2024-12-02 22:19 ` [PATCH 2/4] remoteproc: wkup_m3: Use devm action to call PM runtime put sync Andrew Davis
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andrew Davis @ 2024-12-02 22:19 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier
Cc: linux-remoteproc, linux-kernel, Andrew Davis
Use device life-cycle managed runtime enable function to simplify probe
and exit paths.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/remoteproc/wkup_m3_rproc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c
index d8be21e717212..35c2145b12db7 100644
--- a/drivers/remoteproc/wkup_m3_rproc.c
+++ b/drivers/remoteproc/wkup_m3_rproc.c
@@ -148,7 +148,9 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
return -ENODEV;
}
- pm_runtime_enable(&pdev->dev);
+ ret = devm_pm_runtime_enable(dev);
+ 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");
@@ -219,7 +221,6 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
rproc_free(rproc);
err:
pm_runtime_put_noidle(dev);
- pm_runtime_disable(dev);
return ret;
}
@@ -230,7 +231,6 @@ static void wkup_m3_rproc_remove(struct platform_device *pdev)
rproc_del(rproc);
rproc_free(rproc);
pm_runtime_put_sync(&pdev->dev);
- pm_runtime_disable(&pdev->dev);
}
#ifdef CONFIG_PM
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] remoteproc: wkup_m3: Use devm action to call PM runtime put sync
2024-12-02 22:19 [PATCH 1/4] remoteproc: wkup_m3: Use devm_pm_runtime_enable() helper Andrew Davis
@ 2024-12-02 22:19 ` Andrew Davis
2024-12-02 22:19 ` [PATCH 3/4] remoteproc: wkup_m3: Use devm_rproc_alloc() helper Andrew Davis
2024-12-02 22:19 ` [PATCH 4/4] remoteproc: wkup_m3: Use devm_rproc_add() helper Andrew Davis
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Davis @ 2024-12-02 22:19 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier
Cc: linux-remoteproc, linux-kernel, Andrew Davis
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>
---
drivers/remoteproc/wkup_m3_rproc.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c
index 35c2145b12db7..2569f041d9cab 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
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] remoteproc: wkup_m3: Use devm_rproc_alloc() helper
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
2024-12-02 22:19 ` [PATCH 4/4] remoteproc: wkup_m3: Use devm_rproc_add() helper Andrew Davis
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Davis @ 2024-12-02 22:19 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/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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] remoteproc: wkup_m3: Use devm_rproc_add() helper
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 ` [PATCH 3/4] remoteproc: wkup_m3: Use devm_rproc_alloc() helper Andrew Davis
@ 2024-12-02 22:19 ` Andrew Davis
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Davis @ 2024-12-02 22:19 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier
Cc: linux-remoteproc, linux-kernel, Andrew Davis
Use the device lifecycle managed add function. This helps prevent mistakes
like deleting out of order in cleanup functions and forgetting to delete
on error paths.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/remoteproc/wkup_m3_rproc.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c
index 30e9ecd75657f..6af9aa4179d0c 100644
--- a/drivers/remoteproc/wkup_m3_rproc.c
+++ b/drivers/remoteproc/wkup_m3_rproc.c
@@ -208,22 +208,13 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
wkupm3->mem[i].dev_addr = be32_to_cpu(*addrp) - l4_offset;
}
- dev_set_drvdata(dev, rproc);
-
- ret = rproc_add(rproc);
+ ret = devm_rproc_add(dev, rproc);
if (ret)
return dev_err_probe(dev, ret, "rproc_add failed\n");
return 0;
}
-static void wkup_m3_rproc_remove(struct platform_device *pdev)
-{
- struct rproc *rproc = platform_get_drvdata(pdev);
-
- rproc_del(rproc);
-}
-
#ifdef CONFIG_PM
static int wkup_m3_rpm_suspend(struct device *dev)
{
@@ -242,7 +233,6 @@ static const struct dev_pm_ops wkup_m3_rproc_pm_ops = {
static struct platform_driver wkup_m3_rproc_driver = {
.probe = wkup_m3_rproc_probe,
- .remove = wkup_m3_rproc_remove,
.driver = {
.name = "wkup_m3_rproc",
.of_match_table = wkup_m3_rproc_of_match,
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] remoteproc: wkup_m3: Use devm action to call PM runtime put sync
2025-08-14 15:39 [PATCH 1/4] remoteproc: wkup_m3: Use devm_pm_runtime_enable() helper Andrew Davis
@ 2025-08-14 15:39 ` Andrew Davis
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Davis @ 2025-08-14 15:39 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Hari Nagalla, Beleswar Padhi
Cc: linux-remoteproc, linux-kernel, Andrew Davis
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>
---
drivers/remoteproc/wkup_m3_rproc.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c
index 35c2145b12db7..2569f041d9cab 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
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-14 15:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 3/4] remoteproc: wkup_m3: Use devm_rproc_alloc() helper Andrew Davis
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 2/4] remoteproc: wkup_m3: Use devm action to call PM runtime put sync Andrew Davis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox