[PATCH v3 2/6] watchdog: starfive: treat pm_runtime_put_sync() positive return as success

From: William Theesfeld

Date: Fri Jun 05 2026 - 13:21:37 EST


pm_runtime_put_sync() can return a positive value to signal a
non-error condition (for example, the device was already in the
requested state); only negative return values are real errors.

Both starfive_wdt_pm_stop() and starfive_wdt_probe() currently treat
any non-zero return as failure: pm_stop returns the value verbatim,
which the watchdog framework propagates as an error, and probe takes
the err_unregister_wdt path even on a successful but non-zero return.

Mask off the positive return value in pm_stop and tighten the probe
check to "< 0" so the legitimate positive return is no longer
mishandled.

Signed-off-by: William Theesfeld <william@xxxxxxxxxxxxx>
---
drivers/watchdog/starfive-wdt.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
index ed8c5711a..e047f52b0 100644
--- a/drivers/watchdog/starfive-wdt.c
+++ b/drivers/watchdog/starfive-wdt.c
@@ -386,9 +386,17 @@ static int starfive_wdt_pm_start(struct watchdog_device *wdd)
static int starfive_wdt_pm_stop(struct watchdog_device *wdd)
{
struct starfive_wdt *wdt = watchdog_get_drvdata(wdd);
+ int ret;

starfive_wdt_stop(wdt);
- return pm_runtime_put_sync(wdd->parent);
+ ret = pm_runtime_put_sync(wdd->parent);
+ /*
+ * pm_runtime_put_sync() can return a positive value to signal a
+ * non-error condition (for example, the device was already in the
+ * requested state and no suspend callback was needed). Only
+ * propagate negative return values as failures.
+ */
+ return ret < 0 ? ret : 0;
}

static int starfive_wdt_set_timeout(struct watchdog_device *wdd,
@@ -503,7 +511,7 @@ static int starfive_wdt_probe(struct platform_device *pdev)
if (!early_enable) {
if (pm_runtime_enabled(&pdev->dev)) {
ret = pm_runtime_put_sync(&pdev->dev);
- if (ret)
+ if (ret < 0)
goto err_unregister_wdt;
}
}
--
2.54.0