diff options
author | Emilio López <emilio@elopez.com.ar> | 2014-03-19 14:19:32 -0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-03-19 15:34:56 -0400 |
commit | 2226013972da1ec0a2aeb13a684180bb2b50e0f3 (patch) | |
tree | 46eb6fa45466430ff9995979607226d4c18f2e87 | |
parent | 5a8ddf26822dcf601a44d35efa8fe162cbc84e62 (diff) |
clk: sunxi: fix some calculations
Some divisor calculations were misrounded, causing higher than requested
rates on some clocks. Fix them up using DIV_ROUND_UP, and replace one
homebrew instance of it as well with the right macro.
Reported-by: Boris BREZILLON <b.brezillon.dev@gmail.com>
Signed-off-by: Emilio López <emilio@elopez.com.ar>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r-- | drivers/clk/sunxi/clk-sunxi.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index ef6ad52b7546..aaec9d7867d0 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c | |||
@@ -299,7 +299,7 @@ static void sun4i_get_apb1_factors(u32 *freq, u32 parent_rate, | |||
299 | if (parent_rate < *freq) | 299 | if (parent_rate < *freq) |
300 | *freq = parent_rate; | 300 | *freq = parent_rate; |
301 | 301 | ||
302 | parent_rate = (parent_rate + (*freq - 1)) / *freq; | 302 | parent_rate = DIV_ROUND_UP(parent_rate, *freq); |
303 | 303 | ||
304 | /* Invalid rate! */ | 304 | /* Invalid rate! */ |
305 | if (parent_rate > 32) | 305 | if (parent_rate > 32) |
@@ -344,7 +344,7 @@ static void sun4i_get_mod0_factors(u32 *freq, u32 parent_rate, | |||
344 | if (*freq > parent_rate) | 344 | if (*freq > parent_rate) |
345 | *freq = parent_rate; | 345 | *freq = parent_rate; |
346 | 346 | ||
347 | div = parent_rate / *freq; | 347 | div = DIV_ROUND_UP(parent_rate, *freq); |
348 | 348 | ||
349 | if (div < 16) | 349 | if (div < 16) |
350 | calcp = 0; | 350 | calcp = 0; |
@@ -385,7 +385,7 @@ static void sun7i_a20_get_out_factors(u32 *freq, u32 parent_rate, | |||
385 | if (*freq > parent_rate) | 385 | if (*freq > parent_rate) |
386 | *freq = parent_rate; | 386 | *freq = parent_rate; |
387 | 387 | ||
388 | div = parent_rate / *freq; | 388 | div = DIV_ROUND_UP(parent_rate, *freq); |
389 | 389 | ||
390 | if (div < 32) | 390 | if (div < 32) |
391 | calcp = 0; | 391 | calcp = 0; |