clk: mediatek: Fix calculation of PLL rate settings
authorJames Liao <jamesjj.liao@mediatek.com>
Fri, 10 Jul 2015 08:39:33 +0000 (16:39 +0800)
committerStephen Boyd <sboyd@codeaurora.org>
Tue, 28 Jul 2015 18:58:54 +0000 (11:58 -0700)
Avoid u32 overflow when calculate post divider setting, and
increase the max post divider setting from 3 (/8) to 4 (/16).

Signed-off-by: James Liao <jamesjj.liao@mediatek.com>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/mediatek/clk-pll.c

index 68af5183cda02ba6b2b679e95dbc71ae6ab9ccbf..0e3f4ef0e87147e374e5d13bb2fca2cd1483d011 100644 (file)
@@ -144,9 +144,9 @@ static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv,
        if (freq > pll->data->fmax)
                freq = pll->data->fmax;
 
-       for (val = 0; val < 4; val++) {
+       for (val = 0; val < 5; val++) {
                *postdiv = 1 << val;
-               if (freq * *postdiv >= fmin)
+               if ((u64)freq * *postdiv >= fmin)
                        break;
        }