Skip to contentSkip to conversation

watchdog: starfive: Check pm_runtime_enabled() before decrementing usage counter

PATCH In review Ji Sheng Teoh 2 participants 2 messages Jan 19, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: starfive: Check pm_runtime_enabled() before decrementing usage counter

In the probe function, pm_runtime_put_sync() will fail on platform with runtime PM disabled.
Check if runtime PM is enabled before calling pm_runtime_put_sync() to fix it.

Fixes db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")
---
 drivers/watchdog/starfive-wdt.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/watchdog/starfive-wdt.c +7 -2
index e28ead24c520..df68ae4acbd7 100644
@@ -494,8 +494,13 @@ static int starfive_wdt_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_exit;
 
-	if (!early_enable)
-		pm_runtime_put_sync(&pdev->dev);
+	if (!early_enable) {
+		if (pm_runtime_enabled(&pdev->dev)) {
+			ret = pm_runtime_put_sync(&pdev->dev);
+			if (ret)
+				goto err_exit;
+		}
+	}
 
 	return 0;
 
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ji Sheng Teoh

In the probe function, pm_runtime_put_sync() will fail on platform with runtime PM disabled.
Check if runtime PM is enabled before calling pm_runtime_put_sync() to fix it.

Fixes db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")

Guenter

Quoted 24 lines
---
  drivers/watchdog/starfive-wdt.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/watchdog/starfive-wdt.c +7 -2
index e28ead24c520..df68ae4acbd7 100644
@@ -494,8 +494,13 @@ static int starfive_wdt_probe(struct platform_device *pdev)
  	if (ret)
  		goto err_exit;
 
-	if (!early_enable)
-		pm_runtime_put_sync(&pdev->dev);
+	if (!early_enable) {
+		if (pm_runtime_enabled(&pdev->dev)) {
+			ret = pm_runtime_put_sync(&pdev->dev);
+			if (ret)
+				goto err_exit;
+		}
+	}
 
  	return 0;