Commit 22260139 authored by Emilio López's avatar Emilio López Committed by Mike Turquette

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: default avatarBoris BREZILLON <b.brezillon.dev@gmail.com>
Signed-off-by: default avatarEmilio López <emilio@elopez.com.ar>
Signed-off-by: default avatarMike Turquette <mturquette@linaro.org>
parent 5a8ddf26
...@@ -299,7 +299,7 @@ static void sun4i_get_apb1_factors(u32 *freq, u32 parent_rate, ...@@ -299,7 +299,7 @@ static void sun4i_get_apb1_factors(u32 *freq, u32 parent_rate,
if (parent_rate < *freq) if (parent_rate < *freq)
*freq = parent_rate; *freq = parent_rate;
parent_rate = (parent_rate + (*freq - 1)) / *freq; parent_rate = DIV_ROUND_UP(parent_rate, *freq);
/* Invalid rate! */ /* Invalid rate! */
if (parent_rate > 32) if (parent_rate > 32)
...@@ -344,7 +344,7 @@ static void sun4i_get_mod0_factors(u32 *freq, u32 parent_rate, ...@@ -344,7 +344,7 @@ static void sun4i_get_mod0_factors(u32 *freq, u32 parent_rate,
if (*freq > parent_rate) if (*freq > parent_rate)
*freq = parent_rate; *freq = parent_rate;
div = parent_rate / *freq; div = DIV_ROUND_UP(parent_rate, *freq);
if (div < 16) if (div < 16)
calcp = 0; calcp = 0;
...@@ -385,7 +385,7 @@ static void sun7i_a20_get_out_factors(u32 *freq, u32 parent_rate, ...@@ -385,7 +385,7 @@ static void sun7i_a20_get_out_factors(u32 *freq, u32 parent_rate,
if (*freq > parent_rate) if (*freq > parent_rate)
*freq = parent_rate; *freq = parent_rate;
div = parent_rate / *freq; div = DIV_ROUND_UP(parent_rate, *freq);
if (div < 32) if (div < 32)
calcp = 0; calcp = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment