diff mbox series

[1/2] drivers: watchdog: marvell_gti: fix zero pretimeout handling

Message ID 20231009044037.514570-1-bbhushan2@marvell.com (mailing list archive)
State New
Headers show
Series [1/2] drivers: watchdog: marvell_gti: fix zero pretimeout handling | expand

Commit Message

Bharat Bhushan Oct. 9, 2023, 4:40 a.m. UTC
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>
---
 drivers/watchdog/marvell_gti_wdt.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Guenter Roeck Oct. 11, 2023, 2:51 p.m. UTC | #1
On Mon, Oct 09, 2023 at 10:10:36AM +0530, Bharat Bhushan wrote:
> 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>

> ---
>  drivers/watchdog/marvell_gti_wdt.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/watchdog/marvell_gti_wdt.c b/drivers/watchdog/marvell_gti_wdt.c
> index d7eb8286e11e..25b7ce0f0738 100644
> --- a/drivers/watchdog/marvell_gti_wdt.c
> +++ b/drivers/watchdog/marvell_gti_wdt.c
> @@ -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);
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/watchdog/marvell_gti_wdt.c b/drivers/watchdog/marvell_gti_wdt.c
index d7eb8286e11e..25b7ce0f0738 100644
--- a/drivers/watchdog/marvell_gti_wdt.c
+++ b/drivers/watchdog/marvell_gti_wdt.c
@@ -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);