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

From: William Theesfeld

Date: Fri Jun 05 2026 - 09:16:07 EST


pm_runtime_put_sync() returns 1 when the device cannot be suspended
because it is still in use (typically due to other runtime PM users
holding references); 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 non-suspended case 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..c821b38d2 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 1 when the device is still in
+ * use (and therefore did not actually suspend). That is not an
+ * error from the caller's point of view; only propagate negative
+ * return values.
+ */
+ 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