diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2019-08-30 15:45:11 +0200 |
---|---|---|
committer | Geert Uytterhoeven <geert+renesas@glider.be> | 2019-10-01 10:24:52 +0200 |
commit | f1195d4ec70b230553bbab80c251c3cd79db715b (patch) | |
tree | cd8a30c8c85c5d912a94046f8c8bdbaeb6a94cad /drivers/clk/renesas | |
parent | clk: renesas: rcar-gen3: Avoid double table iteration in SD .set_rate() (diff) | |
download | linux-f1195d4ec70b230553bbab80c251c3cd79db715b.tar.xz linux-f1195d4ec70b230553bbab80c251c3cd79db715b.zip |
clk: renesas: rcar-gen3: Absorb cpg_sd_clock_calc_div()
cpg_sd_clock_round_rate() is the sole caller of cpg_sd_clock_calc_div(),
hence absorb the latter into the former.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20190830134515.11925-5-geert+renesas@glider.be
Diffstat (limited to 'drivers/clk/renesas')
-rw-r--r-- | drivers/clk/renesas/rcar-gen3-cpg.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/clk/renesas/rcar-gen3-cpg.c b/drivers/clk/renesas/rcar-gen3-cpg.c index 0866be30dc72..261f72983096 100644 --- a/drivers/clk/renesas/rcar-gen3-cpg.c +++ b/drivers/clk/renesas/rcar-gen3-cpg.c @@ -309,15 +309,15 @@ static unsigned long cpg_sd_clock_recalc_rate(struct clk_hw *hw, clock->div_table[clock->cur_div_idx].div); } -static unsigned int cpg_sd_clock_calc_div(struct sd_clock *clock, - unsigned long rate, - unsigned long parent_rate) +static long cpg_sd_clock_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) { unsigned long calc_rate, diff, diff_min = ULONG_MAX; + struct sd_clock *clock = to_sd_clock(hw); unsigned int i, best_div = 0; for (i = 0; i < clock->div_num; i++) { - calc_rate = DIV_ROUND_CLOSEST(parent_rate, + calc_rate = DIV_ROUND_CLOSEST(*parent_rate, clock->div_table[i].div); diff = calc_rate > rate ? calc_rate - rate : rate - calc_rate; if (diff < diff_min) { @@ -326,16 +326,7 @@ static unsigned int cpg_sd_clock_calc_div(struct sd_clock *clock, } } - return best_div; -} - -static long cpg_sd_clock_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *parent_rate) -{ - struct sd_clock *clock = to_sd_clock(hw); - unsigned int div = cpg_sd_clock_calc_div(clock, rate, *parent_rate); - - return DIV_ROUND_CLOSEST(*parent_rate, div); + return DIV_ROUND_CLOSEST(*parent_rate, best_div); } static int cpg_sd_clock_set_rate(struct clk_hw *hw, unsigned long rate, |