Skip to contentSkip to conversation

watchdog: ebc-c384_wdt: Simplify ebc_c384_wdt_start timeout computation

PATCH In review William Breathitt Gray 2 participants 3 messages May 11, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: ebc-c384_wdt: Simplify ebc_c384_wdt_start timeout computation

The ebc_c384_wdt_set_timeout function already rounds up timeout values greater than 255 to a multiple of 60, so there is no need to round again in the ebc_c384_wdt_start function; a timeout value greater than 255 in ebc_c384_wdt_start will divide cleanly by 60.

---
 drivers/watchdog/ebc-c384_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/ebc-c384_wdt.c +1 -1
index 77fda0b..948e687 100644
@@ -51,7 +51,7 @@ static int ebc_c384_wdt_start(struct watchdog_device *wdev)
 
 	/* resolution is in minutes for timeouts greater than 255 seconds */
 	if (t > 255)
-		t = DIV_ROUND_UP(t, 60);
+		t /= 60;
 
 	outb(t, PET_ADDR);
 
Signature · 1 line
2.7.3
maintainer
#1 lore raw
Quoted 5 lines · William Breathitt Gray

The ebc_c384_wdt_set_timeout function already rounds up timeout values greater than 255 to a multiple of 60, so there is no need to round again in the ebc_c384_wdt_start function; a timeout value greater than 255 in ebc_c384_wdt_start will divide cleanly by 60.

... except if the timeout is set with the module parameter, which is now rounded down, which would be a problem since it would time out earlier than expected (a timeout of 299 seconds, set with the module parameter, would time out after 240 seconds). So you would have to do some calculations on the timeout value set with the module parameter to ensure that it is set to a correct value.

Guenter

Quoted 21 lines
---
 drivers/watchdog/ebc-c384_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/ebc-c384_wdt.c +1 -1
index 77fda0b..948e687 100644
@@ -51,7 +51,7 @@ static int ebc_c384_wdt_start(struct watchdog_device *wdev)
 
 	/* resolution is in minutes for timeouts greater than 255 seconds */
 	if (t > 255)
-		t = DIV_ROUND_UP(t, 60);
+		t /= 60;
 
 	outb(t, PET_ADDR);
 
Signature · 1 line
2.7.3
#2 lore raw
Quoted 6 lines · Guenter Roeck
Quoted 5 lines · William Breathitt Gray

The ebc_c384_wdt_set_timeout function already rounds up timeout values greater than 255 to a multiple of 60, so there is no need to round again in the ebc_c384_wdt_start function; a timeout value greater than 255 in ebc_c384_wdt_start will divide cleanly by 60.

Quoted 8 lines

... except if the timeout is set with the module parameter, which is now rounded down, which would be a problem since it would time out earlier than expected (a timeout of 299 seconds, set with the module parameter, would time out after 240 seconds). So you would have to do some calculations on the timeout value set with the module parameter to ensure that it is set to a correct value.

Guenter

Oops, I overlooked that scenario. Please ignore this patch as your are correct that a timeout set via module parameter would not necessarily be a multiple of 60; timeout in the start callback should indeed be rounded.

William Breathitt Gray