Commit 2316a7a3 authored by Alex Frid's avatar Alex Frid Committed by Stephen Boyd

clk: Don't write error code into divider register

Add a check for error returned by divider value calculation to avoid
writing error code into hw register.
Signed-off-by: default avatarAlex Frid <afrid@nvidia.com>
Reviewed-by: default avatarPeter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-by: default avatarJon Mayo <jmayo@nvidia.com>
Fixes: bca9690b ("clk: divider: Make generic for usage elsewhere")
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent 6c264416
......@@ -385,12 +385,14 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct clk_divider *divider = to_clk_divider(hw);
unsigned int value;
int value;
unsigned long flags = 0;
u32 val;
value = divider_get_val(rate, parent_rate, divider->table,
divider->width, divider->flags);
if (value < 0)
return value;
if (divider->lock)
spin_lock_irqsave(divider->lock, flags);
......@@ -403,7 +405,7 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
val = clk_readl(divider->reg);
val &= ~(div_mask(divider->width) << divider->shift);
}
val |= value << divider->shift;
val |= (u32)value << divider->shift;
clk_writel(val, divider->reg);
if (divider->lock)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment