From: Vignesh Raghavendra <vigneshr@ti.com>
To: Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>
Cc: Tero Kristo <t-kristo@kernel.org>,
<linux-watchdog@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Vignesh Raghavendra <vigneshr@ti.com>,
<linux-arm-kernel@lists.infradead.org>, <afd@ti.com>,
<n-francis@ti.com>
Subject: [PATCH 1/2] watchdog: rti_wdt: Use managed APIs to handle runtime PM
Date: Fri, 10 Nov 2023 15:37:25 +0530 [thread overview]
Message-ID: <20231110100726.2930218-2-vigneshr@ti.com> (raw)
In-Reply-To: <20231110100726.2930218-1-vigneshr@ti.com>
Switch to devm_pm_runtime_enable() to simplify error handling in driver
probe.
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
drivers/watchdog/rti_wdt.c | 30 ++++++++----------------------
1 file changed, 8 insertions(+), 22 deletions(-)
diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
index 8e1be7ba0103..163bdeb6929a 100644
--- a/drivers/watchdog/rti_wdt.c
+++ b/drivers/watchdog/rti_wdt.c
@@ -236,12 +236,8 @@ static int rti_wdt_probe(struct platform_device *pdev)
if (wdt->freq < 32768)
wdt->freq = wdt->freq * 9 / 10;
- pm_runtime_enable(dev);
- ret = pm_runtime_resume_and_get(dev);
- if (ret < 0) {
- pm_runtime_disable(&pdev->dev);
- return dev_err_probe(dev, ret, "runtime pm failed\n");
- }
+ devm_pm_runtime_enable(dev);
+ pm_runtime_get_noresume(dev);
platform_set_drvdata(pdev, wdt);
@@ -260,7 +256,7 @@ static int rti_wdt_probe(struct platform_device *pdev)
wdt->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(wdt->base)) {
ret = PTR_ERR(wdt->base);
- goto err_iomap;
+ return ret;
}
if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) {
@@ -286,7 +282,7 @@ static int rti_wdt_probe(struct platform_device *pdev)
ret = rti_wdt_setup_hw_hb(wdd, wsize);
if (ret) {
dev_err(dev, "bad window size.\n");
- goto err_iomap;
+ return ret;
}
last_ping = heartbeat_ms - time_left_ms;
@@ -301,7 +297,7 @@ static int rti_wdt_probe(struct platform_device *pdev)
ret = of_address_to_resource(node, 0, &res);
if (ret) {
dev_err(dev, "No memory address assigned to the region.\n");
- goto err_iomap;
+ return ret;
}
/*
@@ -312,15 +308,13 @@ static int rti_wdt_probe(struct platform_device *pdev)
reserved_mem_size = resource_size(&res);
if (reserved_mem_size < RESERVED_MEM_MIN_SIZE) {
dev_err(dev, "The size of reserved memory is too small.\n");
- ret = -EINVAL;
- goto err_iomap;
+ return -EINVAL;
}
vaddr = memremap(paddr, reserved_mem_size, MEMREMAP_WB);
if (!vaddr) {
dev_err(dev, "Failed to map memory-region.\n");
- ret = -ENOMEM;
- goto err_iomap;
+ return -ENOMEM;
}
if (vaddr[0] == PON_REASON_SOF_NUM &&
@@ -337,19 +331,13 @@ static int rti_wdt_probe(struct platform_device *pdev)
ret = watchdog_register_device(wdd);
if (ret) {
dev_err(dev, "cannot register watchdog device\n");
- goto err_iomap;
+ return ret;
}
if (last_ping)
watchdog_set_last_hw_keepalive(wdd, last_ping);
return 0;
-
-err_iomap:
- pm_runtime_put_sync(&pdev->dev);
- pm_runtime_disable(&pdev->dev);
-
- return ret;
}
static void rti_wdt_remove(struct platform_device *pdev)
@@ -357,8 +345,6 @@ static void rti_wdt_remove(struct platform_device *pdev)
struct rti_wdt_device *wdt = platform_get_drvdata(pdev);
watchdog_unregister_device(&wdt->wdd);
- pm_runtime_put(&pdev->dev);
- pm_runtime_disable(&pdev->dev);
}
static const struct of_device_id rti_wdt_of_match[] = {
--
2.42.0
next prev parent reply other threads:[~2023-11-10 18:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 10:07 [PATCH 0/2] watchdog: rti_wdt: Disable module when unused Vignesh Raghavendra
2023-11-10 10:07 ` Vignesh Raghavendra [this message]
2023-11-10 15:03 ` [PATCH 1/2] watchdog: rti_wdt: Use managed APIs to handle runtime PM Guenter Roeck
2023-11-21 4:00 ` Vignesh Raghavendra
2023-11-10 10:07 ` [PATCH 2/2] watchdog: rti_wdt: Drop RPM watchdog when unused Vignesh Raghavendra
2023-11-10 15:05 ` Guenter Roeck
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=20231110100726.2930218-2-vigneshr@ti.com \
--to=vigneshr@ti.com \
--cc=afd@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=n-francis@ti.com \
--cc=t-kristo@kernel.org \
--cc=wim@linux-watchdog.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