Commit f5edaefe authored by Jerome Brunet's avatar Jerome Brunet Committed by Stephen Boyd

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: default avatarJerome Brunet <jbrunet@baylibre.com>
Signed-off-by: default avatarMichael Turquette <mturquette@baylibre.com>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent b15ee490
...@@ -28,22 +28,14 @@ static long div_round_ro_rate(struct clk_hw *hw, unsigned long rate, ...@@ -28,22 +28,14 @@ static long div_round_ro_rate(struct clk_hw *hw, unsigned long rate,
{ {
struct clk_regmap_div *divider = to_clk_regmap_div(hw); struct clk_regmap_div *divider = to_clk_regmap_div(hw);
struct clk_regmap *clkr = &divider->clkr; struct clk_regmap *clkr = &divider->clkr;
u32 div; u32 val;
struct clk_hw *hw_parent = clk_hw_get_parent(hw);
regmap_read(clkr->regmap, divider->reg, &div);
div >>= divider->shift;
div &= BIT(divider->width) - 1;
div += 1;
if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
if (!hw_parent)
return -EINVAL;
*prate = clk_hw_round_rate(hw_parent, rate * div); regmap_read(clkr->regmap, divider->reg, &val);
} val >>= divider->shift;
val &= BIT(divider->width) - 1;
return DIV_ROUND_UP_ULL((u64)*prate, div); return divider_ro_round_rate(hw, rate, prate, NULL, divider->width,
CLK_DIVIDER_ROUND_CLOSEST, val);
} }
static long div_round_rate(struct clk_hw *hw, unsigned long rate, static long div_round_rate(struct clk_hw *hw, unsigned long rate,
......
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