projects
/
firefly-linux-kernel-4.4.55.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b926b11
)
watchdog: dw_wdt: fix overflow issue in dw_wdt_top_in_seconds
author
Huibin Hong
<huibin.hong@rock-chips.com>
Thu, 27 Jul 2017 12:27:09 +0000
(20:27 +0800)
committer
Huang, Tao
<huangtao@rock-chips.com>
Fri, 28 Jul 2017 09:52:33 +0000
(17:52 +0800)
If top is 15, (1 << (16 + top)) may be negative.
Change-Id: I76e4a603a54f093e64a4b266008570e3afcdb35a
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
drivers/watchdog/dw_wdt.c
patch
|
blob
|
history
diff --git
a/drivers/watchdog/dw_wdt.c
b/drivers/watchdog/dw_wdt.c
index 6ea0634345e99512eefec4f82ebcd8ee348bac82..059c9746f5f7131a668a66f7dd6e8403a5e9b6cc 100644
(file)
--- a/
drivers/watchdog/dw_wdt.c
+++ b/
drivers/watchdog/dw_wdt.c
@@
-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)