diff mbox series

[v1] watchdog: starfive: Fix the probe return error if PM and early_enable are both disabled

Message ID 20230425100456.32718-1-xingyu.wu@starfivetech.com
State New
Headers show
Series [v1] watchdog: starfive: Fix the probe return error if PM and early_enable are both disabled | expand

Commit Message

Xingyu Wu April 25, 2023, 10:04 a.m. UTC
When the starfive watchdog driver uses 'pm_runtime_put_sync()' as probe
return value at last and 'early_enable' is disabled, it could return the
error '-ENOSYS' if the CONFIG_PM is disabled, but the driver should works
normally.

Add a check to make sure the PM is enabled and then use
'pm_runtime_put_sync()' as return value when 'early_enable' is disabled.

Fixes: db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")
Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
---

Hi, Guenter and Wim,

This patch fixes the issue of StarFive watchdog driver and rebases on
the master branch of linux-next.

Thanks.
 
---
 drivers/watchdog/starfive-wdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
index 1995cceca51e..51e487e09960 100644
--- a/drivers/watchdog/starfive-wdt.c
+++ b/drivers/watchdog/starfive-wdt.c
@@ -492,7 +492,8 @@  static int starfive_wdt_probe(struct platform_device *pdev)
 		goto err_exit;
 
 	if (!early_enable)
-		return pm_runtime_put_sync(&pdev->dev);
+		if (pm_runtime_enabled(&pdev->dev))
+			return pm_runtime_put_sync(&pdev->dev);
 
 	return 0;