summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-fixed-factor.c
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@gmail.com>2012-12-03 09:14:37 +0100
committerMike Turquette <mturquette@linaro.org>2013-01-12 03:43:27 +0100
commitbab53301c3846ae9a5e1142dca2976f434f70481 (patch)
tree2d872a2a8fc40d6f4975ee153f8d76f227d7813a /drivers/clk/clk-fixed-factor.c
parentclk: export __clk_get_name for re-use in imx-ipu-v3 and others (diff)
downloadlinux-bab53301c3846ae9a5e1142dca2976f434f70481.tar.xz
linux-bab53301c3846ae9a5e1142dca2976f434f70481.zip
clk: fixed-factor: round_rate should use do_div
clk->rate = parent->rate / div * mult The formula is OK. But it may overflow while we do operate with unsigned long. So use do_div instead. Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com> Signed-off-by: Mike Turquette <mturquette@linaro.org> [mturquette@linaro.org: improved $SUBJECT]
Diffstat (limited to 'drivers/clk/clk-fixed-factor.c')
-rw-r--r--drivers/clk/clk-fixed-factor.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index a4899855c0f6..1ef271e47594 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -28,8 +28,11 @@ static unsigned long clk_factor_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct clk_fixed_factor *fix = to_clk_fixed_factor(hw);
+ unsigned long long int rate;
- return parent_rate * fix->mult / fix->div;
+ rate = (unsigned long long int)parent_rate * fix->mult;
+ do_div(rate, fix->div);
+ return (unsigned long)rate;
}
static long clk_factor_round_rate(struct clk_hw *hw, unsigned long rate,