summaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorTony Prisk <linux@prisktech.co.nz>2012-12-27 13:14:31 +1300
committerMike Turquette <mturquette@linaro.org>2013-01-15 16:16:25 -0800
commit58eb5a6763deab71208fbff15b09055fac884b11 (patch)
treebb5391c140cda7c3c6675f02380f88bbe6babd95 /drivers/clk
parent72480014b86c8b51fb51c5c6a0525876055c37c7 (diff)
downloadop-kernel-dev-58eb5a6763deab71208fbff15b09055fac884b11.zip
op-kernel-dev-58eb5a6763deab71208fbff15b09055fac884b11.tar.gz
clk: vt8500: Fix division-by-0 when requested rate=0
A request to vt8500_dclk_(round_rate/set_rate) with rate=0 results in a division-by-0 in the kernel. Signed-off-by: Tony Prisk <linux@prisktech.co.nz> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/clk-vt8500.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
index 3306c2b..db7d41f 100644
--- a/drivers/clk/clk-vt8500.c
+++ b/drivers/clk/clk-vt8500.c
@@ -121,7 +121,12 @@ static long vt8500_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *prate)
{
struct clk_device *cdev = to_clk_device(hw);
- u32 divisor = *prate / rate;
+ u32 divisor;
+
+ if (rate == 0)
+ return 0;
+
+ divisor = *prate / rate;
/* If prate / rate would be decimal, incr the divisor */
if (rate * divisor < *prate)
@@ -142,9 +147,14 @@ static int vt8500_dclk_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct clk_device *cdev = to_clk_device(hw);
- u32 divisor = parent_rate / rate;
+ u32 divisor;
unsigned long flags = 0;
+ if (rate == 0)
+ return 0;
+
+ divisor = parent_rate / rate;
+
/* If prate / rate would be decimal, incr the divisor */
if (rate * divisor < *prate)
divisor++;
OpenPOWER on IntegriCloud