Skip to contentSkip to conversation

Fix set_timeout for big timeout values

PATCH Superseded Georg Hofmann 2 participants 3 messages Apr 8, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix set_timeout for big timeout values

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.

---
 drivers/watchdog/imx2_wdt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/watchdog/imx2_wdt.c +4 -2
index 2b52514..3c13adc 100644
@@ -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;
 }
Signature · 1 line
2.7.4
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Georg Hofmann

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.

Quoted 25 lines
---
 drivers/watchdog/imx2_wdt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/watchdog/imx2_wdt.c +4 -2
index 2b52514..3c13adc 100644
@@ -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;
 }
Signature · 2 lines
-- 
2.7.4
maintainer
#2 lore raw
In reply to Georg Hofmann
Quoted 7 lines · Georg Hofmann

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.

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

Quoted 25 lines
---
 drivers/watchdog/imx2_wdt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/watchdog/imx2_wdt.c +4 -2
index 2b52514..3c13adc 100644
@@ -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;
 }
Signature · 2 lines
-- 
2.7.4