linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] watchdog: imx2_wdt: Fix set_timeout for big timeout values
@ 2019-04-08 19:25 Georg Hofmann
  2019-04-08 19:42 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Georg Hofmann @ 2019-04-08 19:25 UTC (permalink / raw)
  To: wim; +Cc: linux, linux-watchdog

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(-)

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;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] watchdog: imx2_wdt: Fix set_timeout for big timeout values
  2019-04-08 19:25 [PATCH v2] watchdog: imx2_wdt: Fix set_timeout for big timeout values Georg Hofmann
@ 2019-04-08 19:42 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2019-04-08 19:42 UTC (permalink / raw)
  To: Georg Hofmann; +Cc: wim, linux-watchdog

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;
>  }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-08 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08 19:25 [PATCH v2] watchdog: imx2_wdt: Fix set_timeout for big timeout values Georg Hofmann
2019-04-08 19:42 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).