diff mbox series

[v4,1/5] watchdog: f71808e_wdt: fix inaccurate report in WDIOC_GETTIMEOUT

Message ID 7f2a07eaa7dbd7c3f8162a89d364c3eef45883ea.1626948810.git-series.a.fatoum@pengutronix.de
State Superseded
Headers show
Series watchdog: f71808e_wdt: migrate to new kernel API | expand

Commit Message

Ahmad Fatoum July 22, 2021, 10:14 a.m. UTC
The fintek watchdog timer can configure timeouts of second granularity
only up to 255 seconds. Beyond that, the timeout needs to be configured
with minute granularity. WDIOC_GETTIMEOUT should report the actual
timeout configured, not just echo back the timeout configured by the
user. Do so.

Fixes: 96cb4eb019ce ("watchdog: f71808e_wdt: new watchdog driver for Fintek F71808E and F71882FG")
Suggested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/watchdog/f71808e_wdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Guenter Roeck July 25, 2021, 9:41 p.m. UTC | #1
On Thu, Jul 22, 2021 at 12:14:40PM +0200, Ahmad Fatoum wrote:
> The fintek watchdog timer can configure timeouts of second granularity

> only up to 255 seconds. Beyond that, the timeout needs to be configured

> with minute granularity. WDIOC_GETTIMEOUT should report the actual

> timeout configured, not just echo back the timeout configured by the

> user. Do so.

> 

> Fixes: 96cb4eb019ce ("watchdog: f71808e_wdt: new watchdog driver for Fintek F71808E and F71882FG")

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

> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>


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


> ---

>  drivers/watchdog/f71808e_wdt.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c

> index f60beec1bbae..f7d82d261913 100644

> --- a/drivers/watchdog/f71808e_wdt.c

> +++ b/drivers/watchdog/f71808e_wdt.c

> @@ -228,15 +228,17 @@ static int watchdog_set_timeout(int timeout)

>  

>  	mutex_lock(&watchdog.lock);

>  

> -	watchdog.timeout = timeout;

>  	if (timeout > 0xff) {

>  		watchdog.timer_val = DIV_ROUND_UP(timeout, 60);

>  		watchdog.minutes_mode = true;

> +		timeout = watchdog.timer_val * 60;

>  	} else {

>  		watchdog.timer_val = timeout;

>  		watchdog.minutes_mode = false;

>  	}

>  

> +	watchdog.timeout = timeout;

> +

>  	mutex_unlock(&watchdog.lock);

>  

>  	return 0;

> -- 

> git-series 0.9.1
diff mbox series

Patch

diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c
index f60beec1bbae..f7d82d261913 100644
--- a/drivers/watchdog/f71808e_wdt.c
+++ b/drivers/watchdog/f71808e_wdt.c
@@ -228,15 +228,17 @@  static int watchdog_set_timeout(int timeout)
 
 	mutex_lock(&watchdog.lock);
 
-	watchdog.timeout = timeout;
 	if (timeout > 0xff) {
 		watchdog.timer_val = DIV_ROUND_UP(timeout, 60);
 		watchdog.minutes_mode = true;
+		timeout = watchdog.timer_val * 60;
 	} else {
 		watchdog.timer_val = timeout;
 		watchdog.minutes_mode = false;
 	}
 
+	watchdog.timeout = timeout;
+
 	mutex_unlock(&watchdog.lock);
 
 	return 0;