diff options
author | Dinh Nguyen <dinguyen@altera.com> | 2014-02-19 16:11:10 -0500 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-02-26 15:23:29 -0500 |
commit | 5585f7317573873f95c1bb7748322c62a6c3a919 (patch) | |
tree | 91c8230f367233a21a4cdb61c72bbb94a5e27e5a /drivers/clk/socfpga | |
parent | 2c97ec58420d852f3f0ede905b92fbab1df5961c (diff) |
clk: socfpga: Fix integer overflow in clock calculation
Use 64-bit integer for calculating clock rate. Also use do_div for the
64-bit division.
Signed-off-by: Graham Moore <grmoore@altera.com>
Signed-off-by: Dinh Nguyen <dinguyen@altera.com>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/socfpga')
-rw-r--r-- | drivers/clk/socfpga/clk-pll.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c index 362004e1e6fe..834b6e961971 100644 --- a/drivers/clk/socfpga/clk-pll.c +++ b/drivers/clk/socfpga/clk-pll.c | |||
@@ -44,7 +44,8 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk, | |||
44 | unsigned long parent_rate) | 44 | unsigned long parent_rate) |
45 | { | 45 | { |
46 | struct socfpga_pll *socfpgaclk = to_socfpga_clk(hwclk); | 46 | struct socfpga_pll *socfpgaclk = to_socfpga_clk(hwclk); |
47 | unsigned long divf, divq, vco_freq, reg; | 47 | unsigned long divf, divq, reg; |
48 | unsigned long long vco_freq; | ||
48 | unsigned long bypass; | 49 | unsigned long bypass; |
49 | 50 | ||
50 | reg = readl(socfpgaclk->hw.reg); | 51 | reg = readl(socfpgaclk->hw.reg); |
@@ -54,8 +55,9 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk, | |||
54 | 55 | ||
55 | divf = (reg & SOCFPGA_PLL_DIVF_MASK) >> SOCFPGA_PLL_DIVF_SHIFT; | 56 | divf = (reg & SOCFPGA_PLL_DIVF_MASK) >> SOCFPGA_PLL_DIVF_SHIFT; |
56 | divq = (reg & SOCFPGA_PLL_DIVQ_MASK) >> SOCFPGA_PLL_DIVQ_SHIFT; | 57 | divq = (reg & SOCFPGA_PLL_DIVQ_MASK) >> SOCFPGA_PLL_DIVQ_SHIFT; |
57 | vco_freq = parent_rate * (divf + 1); | 58 | vco_freq = (unsigned long long)parent_rate * (divf + 1); |
58 | return vco_freq / (1 + divq); | 59 | do_div(vco_freq, (1 + divq)); |
60 | return (unsigned long)vco_freq; | ||
59 | } | 61 | } |
60 | 62 | ||
61 | static struct clk_ops clk_pll_ops = { | 63 | static struct clk_ops clk_pll_ops = { |