watchdog: starfive: check watchdog status before enabling in system resume
authorJi Sheng Teoh <jisheng.teoh@starfivetech.com>
Tue, 30 Jan 2024 05:51:18 +0000 (13:51 +0800)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sun, 3 Mar 2024 13:17:29 +0000 (14:17 +0100)
System resume will start and enable watchdog regardless of whether the
watchdog is enabled/disabled during a system suspend.
Add a check to the watchdog status and only start and enable the
watchdog if the watchdog status is running/active.

Signed-off-by: Sia Jee Heng <jeeheng.sia@starfivetech.com>
Signed-off-by: Ji Sheng Teoh <jisheng.teoh@starfivetech.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20240130055118.1917086-1-jisheng.teoh@starfivetech.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/starfive-wdt.c

index df68ae4acbd7ef735cd01ead17e29cbad90ec908..b4b059883618b94e8b8d77d9170b5f8cd71c7419 100644 (file)
@@ -559,7 +559,10 @@ static int starfive_wdt_resume(struct device *dev)
        starfive_wdt_set_reload_count(wdt, wdt->reload);
        starfive_wdt_lock(wdt);
 
-       return starfive_wdt_start(wdt);
+       if (watchdog_active(&wdt->wdd))
+               return starfive_wdt_start(wdt);
+
+       return 0;
 }
 
 static int starfive_wdt_runtime_suspend(struct device *dev)