diff options
author | Tomasz Figa <t.figa@samsung.com> | 2014-05-07 20:24:10 +0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-05-28 06:16:24 +0400 |
commit | 3c17296f28820d2a9fa23e549a1e808a4df5dfc6 (patch) | |
tree | 8db88c283396e3ccc5814fec88a205a553f5a04a /drivers/clk/clk-divider.c | |
parent | 65e75d42b386d2490c7477bf740c2843167beda8 (diff) | |
download | linux-3c17296f28820d2a9fa23e549a1e808a4df5dfc6.tar.xz |
clk: divider: Fix overflow in clk_divider_bestdiv
Commit c686078 ("clk: divider: Add round to closest divider") introduced
a helper function to check whether given divisor is the best one instead
of direct check. However due to int type used instead of unsigned long
for passing calculated rates to this function in certain cases an
overflow could occur, for example when trying to obtain maximum possible
clock rate by calling clk_round_rate(..., UINT_MAX).
This patch fixes this issue by changing the type of rate, now and best
arguments of the function to unsigned long, which is the type that
should be used for clock rates.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Maxime Coquelin <maxime.coquelin@st.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/clk-divider.c')
-rw-r--r-- | drivers/clk/clk-divider.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index 47eabfab3706..18a9de29df0e 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -232,7 +232,7 @@ static int _div_round(struct clk_divider *divider, unsigned long parent_rate, } static bool _is_best_div(struct clk_divider *divider, - int rate, int now, int best) + unsigned long rate, unsigned long now, unsigned long best) { if (divider->flags & CLK_DIVIDER_ROUND_CLOSEST) return abs(rate - now) < abs(rate - best); |