Skip to content

Commit

Permalink
clk: fix some determine_rate implementations
Browse files Browse the repository at this point in the history
Some determine_rate implementations are not returning an error
when they failed to adapt the rate according to the rate request.
Fix them so that they return an error instead of silently
returning 0.

Signed-off-by: Boris Brezillon <[email protected]>
CC: Jonathan Corbet <[email protected]>
CC: Tony Lindgren <[email protected]>
CC: Ralf Baechle <[email protected]>
CC: "Emilio López" <[email protected]>
CC: Maxime Ripard <[email protected]>
Cc: Tero Kristo <[email protected]>
CC: Peter De Schrijver <[email protected]>
CC: Prashant Gaikwad <[email protected]>
CC: Stephen Warren <[email protected]>
CC: Thierry Reding <[email protected]>
CC: Alexandre Courbot <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
Signed-off-by: Stephen Boyd <[email protected]>
  • Loading branch information
Boris Brezillon authored and bebarino committed Jul 28, 2015
1 parent 0817b62 commit 57d866e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions arch/mips/alchemy/common/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,13 @@ static int alchemy_clk_fgcs_detr(struct clk_hw *hw,
}
}

if (br < 0)
return br;

req->best_parent_rate = bpr;
req->best_parent_hw = __clk_get_hw(bpc);
req->rate = br;

return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/clk/clk-composite.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
return mux_ops->determine_rate(mux_hw, req);
} else {
pr_err("clk: clk_composite_determine_rate function called, but no mux or rate callback set!\n");
req->rate = 0;
return 0;
return -EINVAL;
}
}

Expand Down
3 changes: 3 additions & 0 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ clk_mux_determine_rate_flags(struct clk_hw *hw, struct clk_rate_request *req,
}
}

if (!best_parent)
return -EINVAL;

out:
if (best_parent)
req->best_parent_hw = best_parent->hw;
Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/hisilicon/clk-hi3620.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static int mmc_clk_determine_rate(struct clk_hw *hw,
req->rate = 180000000;
req->best_parent_rate = 1440000000;
}
return 0;
return -EINVAL;
}

static u32 mmc_clk_delay(u32 val, u32 para, u32 off, u32 len)
Expand Down
5 changes: 4 additions & 1 deletion drivers/clk/mmp/clk-mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static int mmp_clk_mix_determine_rate(struct clk_hw *hw,
parent = NULL;
mix_rate_best = 0;
parent_rate_best = 0;
gap_best = req->rate;
gap_best = ULONG_MAX;
parent_best = NULL;

if (mix->table) {
Expand Down Expand Up @@ -262,6 +262,9 @@ static int mmp_clk_mix_determine_rate(struct clk_hw *hw,
}

found:
if (!parent_best)
return -EINVAL;

req->best_parent_rate = parent_rate_best;
req->best_parent_hw = __clk_get_hw(parent_best);
req->rate = mix_rate_best;
Expand Down
6 changes: 4 additions & 2 deletions drivers/clk/sunxi/clk-factors.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ static int clk_factors_determine_rate(struct clk_hw *hw,
}
}

if (best_parent)
req->best_parent_hw = __clk_get_hw(best_parent);
if (!best_parent)
return -EINVAL;

req->best_parent_hw = __clk_get_hw(best_parent);
req->best_parent_rate = best;
req->rate = best_child_rate;

Expand Down
3 changes: 3 additions & 0 deletions drivers/clk/sunxi/clk-sun6i-ar100.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ static int ar100_determine_rate(struct clk_hw *hw,
}
}

if (best_rate < 0)
return best_rate;

req->rate = best_rate;

return 0;
Expand Down
6 changes: 4 additions & 2 deletions drivers/clk/sunxi/clk-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ static int sun6i_ahb1_clk_determine_rate(struct clk_hw *hw,
}
}

if (best_parent)
req->best_parent_hw = __clk_get_hw(best_parent);
if (!best_parent)
return -EINVAL;

req->best_parent_hw = __clk_get_hw(best_parent);
req->best_parent_rate = best;
req->rate = best_child_rate;

Expand Down

0 comments on commit 57d866e

Please sign in to comment.