Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: qcom: use divider_ro_round_rate helper

There is now an helper function to round the rate when the
divider is read-only. Let's use it

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Jerome Brunet and committed by
Stephen Boyd
f5edaefe b15ee490

+6 -14
+6 -14
drivers/clk/qcom/clk-regmap-divider.c
··· 28 28 { 29 29 struct clk_regmap_div *divider = to_clk_regmap_div(hw); 30 30 struct clk_regmap *clkr = &divider->clkr; 31 - u32 div; 32 - struct clk_hw *hw_parent = clk_hw_get_parent(hw); 31 + u32 val; 33 32 34 - regmap_read(clkr->regmap, divider->reg, &div); 35 - div >>= divider->shift; 36 - div &= BIT(divider->width) - 1; 37 - div += 1; 33 + regmap_read(clkr->regmap, divider->reg, &val); 34 + val >>= divider->shift; 35 + val &= BIT(divider->width) - 1; 38 36 39 - if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { 40 - if (!hw_parent) 41 - return -EINVAL; 42 - 43 - *prate = clk_hw_round_rate(hw_parent, rate * div); 44 - } 45 - 46 - return DIV_ROUND_UP_ULL((u64)*prate, div); 37 + return divider_ro_round_rate(hw, rate, prate, NULL, divider->width, 38 + CLK_DIVIDER_ROUND_CLOSEST, val); 47 39 } 48 40 49 41 static long div_round_rate(struct clk_hw *hw, unsigned long rate,