diff mbox series

[v2] watchdog: imx2_wdt: Fix set_timeout for big timeout values

Message ID 66814249.3190.1554751554223.JavaMail.zimbra@hofmannsweb.com (mailing list archive)
State Accepted
Headers show
Series [v2] watchdog: imx2_wdt: Fix set_timeout for big timeout values | expand

Commit Message

Georg Hofmann April 8, 2019, 7:25 p.m. UTC
The documentated behavior is: if max_hw_heartbeat_ms is implemented, the
minimum of the set_timeout argument and max_hw_heartbeat_ms should be used.
This patch implements this behavior.
Previously only the first 7bits were used and the input argument was
returned.

Signed-off-by: Georg Hofmann <georg@hofmannsweb.com>
---
 drivers/watchdog/imx2_wdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Guenter Roeck April 8, 2019, 7:42 p.m. UTC | #1
On Mon, Apr 08, 2019 at 09:25:54PM +0200, Georg Hofmann wrote:
> The documentated behavior is: if max_hw_heartbeat_ms is implemented, the
> minimum of the set_timeout argument and max_hw_heartbeat_ms should be used.
> This patch implements this behavior.
> Previously only the first 7bits were used and the input argument was
> returned.
> 
> Signed-off-by: Georg Hofmann <georg@hofmannsweb.com>

This time it applied, thanks.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

Guenter

> ---
>  drivers/watchdog/imx2_wdt.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> index 2b52514..7e7bdcb 100644
> --- a/drivers/watchdog/imx2_wdt.c
> +++ b/drivers/watchdog/imx2_wdt.c
> @@ -178,8 +178,10 @@ static void __imx2_wdt_set_timeout(struct watchdog_device *wdog,
>  static int imx2_wdt_set_timeout(struct watchdog_device *wdog,
>  				unsigned int new_timeout)
>  {
> -	__imx2_wdt_set_timeout(wdog, new_timeout);
> +	unsigned int actual;
>  
> +	actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000);
> +	__imx2_wdt_set_timeout(wdog, actual);
>  	wdog->timeout = new_timeout;
>  	return 0;
>  }
diff mbox series

Patch

diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index 2b52514..7e7bdcb 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -178,8 +178,10 @@  static void __imx2_wdt_set_timeout(struct watchdog_device *wdog,
 static int imx2_wdt_set_timeout(struct watchdog_device *wdog,
 				unsigned int new_timeout)
 {
-	__imx2_wdt_set_timeout(wdog, new_timeout);
+	unsigned int actual;
 
+	actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000);
+	__imx2_wdt_set_timeout(wdog, actual);
 	wdog->timeout = new_timeout;
 	return 0;
 }