From: Andrew Davis <afd@ti.com>
To: Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: <linux-remoteproc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Andrew Davis <afd@ti.com>
Subject: [PATCH v2 3/5] remoteproc: keystone: Use devm action to call PM runtime put sync
Date: Mon, 2 Dec 2024 15:51:33 -0600 [thread overview]
Message-ID: <20241202215135.294829-3-afd@ti.com> (raw)
In-Reply-To: <20241202215135.294829-1-afd@ti.com>
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/keystone_remoteproc.c | 36 ++++++++++++------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c
index 2af3b64bc239c..1032f440426da 100644
--- a/drivers/remoteproc/keystone_remoteproc.c
+++ b/drivers/remoteproc/keystone_remoteproc.c
@@ -365,6 +365,13 @@ static void keystone_rproc_mem_release(void *data)
of_reserved_mem_device_release(dev);
}
+static void keystone_rproc_pm_runtime_put(void *data)
+{
+ struct device *dev = data;
+
+ pm_runtime_put_sync(dev);
+}
+
static int keystone_rproc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -417,30 +424,26 @@ static int keystone_rproc_probe(struct platform_device *pdev)
ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return dev_err_probe(dev, ret, "failed to enable clock\n");
+ ret = devm_add_action_or_reset(dev, keystone_rproc_pm_runtime_put, dev);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to add disable pm devm action\n");
ret = keystone_rproc_of_get_memories(pdev, ksproc);
if (ret)
- goto disable_clk;
+ return ret;
ksproc->irq_ring = platform_get_irq_byname(pdev, "vring");
- if (ksproc->irq_ring < 0) {
- ret = ksproc->irq_ring;
- goto disable_clk;
- }
+ if (ksproc->irq_ring < 0)
+ return ksproc->irq_ring;
ksproc->irq_fault = platform_get_irq_byname(pdev, "exception");
- if (ksproc->irq_fault < 0) {
- ret = ksproc->irq_fault;
- goto disable_clk;
- }
+ if (ksproc->irq_fault < 0)
+ return ksproc->irq_fault;
ksproc->kick_gpio = gpiod_get(dev, "kick", GPIOD_ASIS);
ret = PTR_ERR_OR_ZERO(ksproc->kick_gpio);
- if (ret) {
- dev_err(dev, "failed to get gpio for virtio kicks, status = %d\n",
- ret);
- goto disable_clk;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to get gpio for virtio kicks\n");
ret = of_reserved_mem_device_init(dev);
if (ret) {
@@ -448,7 +451,7 @@ static int keystone_rproc_probe(struct platform_device *pdev)
} else {
ret = devm_add_action_or_reset(dev, keystone_rproc_mem_release, dev);
if (ret)
- goto disable_clk;
+ return ret;
}
/* ensure the DSP is in reset before loading firmware */
@@ -474,8 +477,6 @@ static int keystone_rproc_probe(struct platform_device *pdev)
release_mem:
gpiod_put(ksproc->kick_gpio);
-disable_clk:
- pm_runtime_put_sync(dev);
return ret;
}
@@ -485,7 +486,6 @@ static void keystone_rproc_remove(struct platform_device *pdev)
rproc_del(ksproc->rproc);
gpiod_put(ksproc->kick_gpio);
- pm_runtime_put_sync(&pdev->dev);
}
static const struct of_device_id keystone_rproc_of_match[] = {
--
2.39.2
next prev parent reply other threads:[~2024-12-02 21:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 21:51 [PATCH v2 1/5] remoteproc: keystone: Use devm action to release reserved memory Andrew Davis
2024-12-02 21:51 ` [PATCH v2 2/5] remoteproc: keystone: Use devm_pm_runtime_enable() helper Andrew Davis
2024-12-02 21:51 ` Andrew Davis [this message]
2024-12-02 21:51 ` [PATCH v2 4/5] remoteproc: keystone: Use devm_gpiod_get() helper Andrew Davis
2024-12-02 21:51 ` [PATCH v2 5/5] remoteproc: keystone: Use devm_rproc_add() helper Andrew Davis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241202215135.294829-3-afd@ti.com \
--to=afd@ti.com \
--cc=andersson@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).