diff mbox series

watchdog: starfive: check watchdog status before enabling in system resume

Message ID 20240130055118.1917086-1-jisheng.teoh@starfivetech.com
State New
Headers show
Series watchdog: starfive: check watchdog status before enabling in system resume | expand

Commit Message

Ji Sheng Teoh Jan. 30, 2024, 5:51 a.m. UTC
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>
---
 drivers/watchdog/starfive-wdt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Guenter Roeck Jan. 30, 2024, 6:07 a.m. UTC | #1
On 1/29/24 21:51, Ji Sheng Teoh wrote:
> 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>

> ---
>   drivers/watchdog/starfive-wdt.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
> index e28ead24c520..f72fc38a41f8 100644
> --- a/drivers/watchdog/starfive-wdt.c
> +++ b/drivers/watchdog/starfive-wdt.c
> @@ -554,7 +554,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)
diff mbox series

Patch

diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
index e28ead24c520..f72fc38a41f8 100644
--- a/drivers/watchdog/starfive-wdt.c
+++ b/drivers/watchdog/starfive-wdt.c
@@ -554,7 +554,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)