diff mbox series

Fix set_timeout for big timeout values

Message ID 869353809.2803.1554710736950.JavaMail.zimbra@hofmannsweb.com (mailing list archive)
State Changes Requested
Headers show
Series Fix set_timeout for big timeout values | expand

Commit Message

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

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

Comments

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

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

> ---
>  drivers/watchdog/imx2_wdt.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> index 2b52514..3c13adc 100644
> --- a/drivers/watchdog/imx2_wdt.c
> +++ b/drivers/watchdog/imx2_wdt.c
> @@ -178,9 +178,11 @@ 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;
>  
> -        wdog->timeout = new_timeout;
> +        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
Guenter Roeck April 8, 2019, 6:15 p.m. UTC | #2
On Mon, Apr 08, 2019 at 10:05:36AM +0200, Georg Hofmann wrote:
> This patch implements the documented behavior: if max_hw_heartbeat_ms is
> implemented, the minimum of the set_timeout argument and
> max_hw_heartbeat_ms should be used.
> Previously only the first 7 bits were used and the input argument was
> returned.
> 
> Signed-off-by: Georg Hofmann <georg@hofmannsweb.com>

The patch below is corrupted (tabs replaced with spaces). Please resend.
Also, when doing so, please add "watchdog: imx2_wdt:" to the subject line.

Thanks,
Guenter

> ---
>  drivers/watchdog/imx2_wdt.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> index 2b52514..3c13adc 100644
> --- a/drivers/watchdog/imx2_wdt.c
> +++ b/drivers/watchdog/imx2_wdt.c
> @@ -178,9 +178,11 @@ 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;
>  
> -        wdog->timeout = new_timeout;
> +        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
diff mbox series

Patch

diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index 2b52514..3c13adc 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -178,9 +178,11 @@  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;
 
-        wdog->timeout = new_timeout;
+        actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000);
+        __imx2_wdt_set_timeout(wdog, actual);

+        wdog->timeout = new_timeout;
         return 0;
 }