diff options
author | Heiko Stübner <heiko@sntech.de> | 2014-08-28 14:46:10 +0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-09-10 20:42:37 +0400 |
commit | feaefa0ea1f1ab3fb92519aef2099ab4d75cce05 (patch) | |
tree | 7895ee89a3f1045280cfa41641bb661fd7954a43 /drivers/clk/clk-fractional-divider.c | |
parent | f82a1d1586a2bd553431cf09d469ece17d1e61e7 (diff) | |
download | linux-feaefa0ea1f1ab3fb92519aef2099ab4d75cce05.tar.xz |
clk: fractional-divider: cast parent_rate to u64 before multiplying
On 32bit architectures, like ARM calculating the fractional rate will
do the multiplication before converting the value to u64 when it gets
assigned to ret, which can produce overflows.
The error in question happened with a parent_rate of 386MHz, m = 3000,
n = 60000, which resulted in a wrong rate value of 15812Hz.
Therefore cast parent_rate to u64 to make sure the multiplication
happens in a 64bit space and produces the correct 192MHz in the example.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/clk-fractional-divider.c')
-rw-r--r-- | drivers/clk/clk-fractional-divider.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c index ede685ca0d20..82a59d0086cc 100644 --- a/drivers/clk/clk-fractional-divider.c +++ b/drivers/clk/clk-fractional-divider.c @@ -36,7 +36,7 @@ static unsigned long clk_fd_recalc_rate(struct clk_hw *hw, m = (val & fd->mmask) >> fd->mshift; n = (val & fd->nmask) >> fd->nshift; - ret = parent_rate * m; + ret = (u64)parent_rate * m; do_div(ret, n); return ret; |