clk: divider: Fix overflow in clk_divider_bestdiv
authorTomasz Figa <t.figa@samsung.com>
Wed, 7 May 2014 16:24:10 +0000 (18:24 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 8 Dec 2014 19:27:16 +0000 (19:27 +0000)
commita25d213c85eddc21d6a403f535ed3b72baee0d7b
treed9f4bdf95d0a4186181250ef2ce756dcb2703c85
parenteb67fcdaa0fb0e40ad4d43190b89b4dead973686
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>
(cherry picked from commit 3c17296f28820d2a9fa23e549a1e808a4df5dfc6)
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/clk/clk-divider.c