watchdog: dw_wdt: fix overflow issue in dw_wdt_top_in_seconds
If top is 15, (1 << (16 + top)) may be negative. Change-Id: I76e4a603a54f093e64a4b266008570e3afcdb35a Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
This commit is contained in:
parent
b926b11cab
commit
e8b7cbd64a
1 changed files with 3 additions and 1 deletions
|
|
@ -81,7 +81,9 @@ static inline int dw_wdt_top_in_seconds(unsigned top)
|
|||
* There are 16 possible timeout values in 0..15 where the number of
|
||||
* cycles is 2 ^ (16 + i) and the watchdog counts down.
|
||||
*/
|
||||
return (1 << (16 + top)) / clk_get_rate(dw_wdt.clk);
|
||||
unsigned int cycles = 1 << (16 + top);
|
||||
|
||||
return cycles / clk_get_rate(dw_wdt.clk);
|
||||
}
|
||||
|
||||
static int dw_wdt_get_top(void)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue