drivers: watchdog: marvell_gti: fix zero pretimeout handling
authorBharat Bhushan <bbhushan2@marvell.com>
Mon, 9 Oct 2023 04:40:36 +0000 (10:10 +0530)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sun, 29 Oct 2023 18:45:08 +0000 (19:45 +0100)
When pretimeout is set to 0 then do not reprogram timer
with zero timeout, this will reset device immediately.
Also disable interrupt to stop pretimeout notification.

Signed-off-by: Bharat Bhushan <bbhushan2@marvell.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20231009044037.514570-1-bbhushan2@marvell.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/marvell_gti_wdt.c

index fcf5d3a8622d1a8369c1315bb14ce5e6c38ea9c1..e8e95c4a6a54e33da9ec33fd1092d8ec725b5275 100644 (file)
@@ -190,6 +190,13 @@ static int gti_wdt_set_pretimeout(struct watchdog_device *wdev,
        struct gti_wdt_priv *priv = watchdog_get_drvdata(wdev);
        struct watchdog_device *wdog_dev = &priv->wdev;
 
+       if (!timeout) {
+               /* Disable Interrupt */
+               writeq(GTI_CWD_INT_ENA_CLR_VAL(priv->wdt_timer_idx),
+                      priv->base + GTI_CWD_INT_ENA_CLR);
+               return 0;
+       }
+
        /* pretimeout should 1/3 of max_timeout */
        if (timeout * 3 <= wdog_dev->max_timeout)
                return gti_wdt_settimeout(wdev, timeout * 3);