Skip to content

Commit 1fc8a2c

Browse files
Changcheng DengWim Van Sebroeck
authored andcommitted
watchdog: davinci: Use div64_ul instead of do_div
do_div() does a 64-by-32 division. Here the divisor is an unsigned long which on some platforms is 64 bit wide. So use div64_ul instead of do_div to avoid a possible truncation. Reported-by: Zeal Robot <[email protected]> Signed-off-by: Changcheng Deng <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent f8d9ba7 commit 1fc8a2c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/watchdog/davinci_wdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static unsigned int davinci_wdt_get_timeleft(struct watchdog_device *wdd)
134134
timer_counter = ioread32(davinci_wdt->base + TIM12);
135135
timer_counter |= ((u64)ioread32(davinci_wdt->base + TIM34) << 32);
136136

137-
do_div(timer_counter, freq);
137+
timer_counter = div64_ul(timer_counter, freq);
138138

139139
return wdd->timeout - timer_counter;
140140
}

0 commit comments

Comments
 (0)