Skip to content

Commit 3322d53

Browse files
mikecroweWim Van Sebroeck
authored andcommitted
watchdog: sp805: Report correct timeleft at maximum
sp805_wdt::load_val is of type unsigned int. When the interrupt is inactive wdt_timeleft adds one to the value, and then adds that to the value used to calculate the time remaining. Unfortunately it's not unlikely that load_val contains LOAD_MAX, which is 0xFFFFFFFF and wraps to zero when one is added to it, resulting in the time left being understated by about 21.7s. Fix this by ensuring the addition happens as 64-bit. Signed-off-by: Mike Crowe <mac@mcrowe.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20241203095744.3001795-1-mac@mcrowe.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
1 parent 6a569e2 commit 3322d53

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/watchdog/sp805_wdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static unsigned int wdt_timeleft(struct watchdog_device *wdd)
128128

129129
/*If the interrupt is inactive then time left is WDTValue + WDTLoad. */
130130
if (!(readl_relaxed(wdt->base + WDTRIS) & INT_MASK))
131-
load += wdt->load_val + 1;
131+
load += (u64)wdt->load_val + 1;
132132
spin_unlock(&wdt->lock);
133133

134134
return div_u64(load, wdt->rate);

0 commit comments

Comments
 (0)