diff options
author | Jerome Brunet <jbrunet@baylibre.com> | 2018-02-14 14:43:40 +0100 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2018-03-12 15:10:27 -0700 |
commit | f5edaefee2d621f4e7628f1421c58a2361572d3a (patch) | |
tree | 41997706f5d1700a7e1d8ab800493677139e7c00 /drivers/clk/qcom | |
parent | b15ee490e16324c35b51f04bad54ae45a2cefd29 (diff) | |
download | linux-stable-f5edaefee2d621f4e7628f1421c58a2361572d3a.tar.gz linux-stable-f5edaefee2d621f4e7628f1421c58a2361572d3a.tar.bz2 linux-stable-f5edaefee2d621f4e7628f1421c58a2361572d3a.zip |
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>
Diffstat (limited to 'drivers/clk/qcom')
-rw-r--r-- | drivers/clk/qcom/clk-regmap-divider.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/drivers/clk/qcom/clk-regmap-divider.c b/drivers/clk/qcom/clk-regmap-divider.c index 4e9b8c2c8980..1ee75a5e93f4 100644 --- a/drivers/clk/qcom/clk-regmap-divider.c +++ b/drivers/clk/qcom/clk-regmap-divider.c @@ -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 *clkr = ÷r->clkr; - u32 div; - 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; + u32 val; - *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, |