mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jerome Brunet <jbrunet@baylibre.com>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: Jerome Brunet <jbrunet@baylibre.com>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 8/8] clk: qcom: use divider_ro_round_rate helper
Date: Wed, 14 Feb 2018 14:43:40 +0100	[thread overview]
Message-ID: <20180214134340.17242-9-jbrunet@baylibre.com> (raw)
In-Reply-To: <20180214134340.17242-1-jbrunet@baylibre.com>

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>
---
 drivers/clk/qcom/clk-regmap-divider.c | 20 ++++++--------------
 1 file 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 = &divider->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,
-- 
2.14.3

  parent reply	other threads:[~2018-02-14 13:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 13:43 [PATCH v2 0/8] clk: helpers and fixes Jerome Brunet
2018-02-14 13:43 ` [PATCH v2 1/8] clk: divider: export clk_div_mask() helper Jerome Brunet
2018-02-14 13:43 ` [PATCH v2 2/8] clk: mux: add helper function for index/value translation Jerome Brunet
2018-02-14 13:43 ` [PATCH v2 3/8] clk: fix determine rate error with pass-through clock Jerome Brunet
2018-02-14 13:43 ` [PATCH v2 4/8] clk: migrate the count of orphaned clocks at init Jerome Brunet
     [not found]   ` <CGME20180215125542eucas1p218f5797e7254c28d9a6437d579220e52@eucas1p2.samsung.com>
2018-02-15 12:55     ` Marek Szyprowski
     [not found]       ` <CGME20180305090647eucas1p14c01d34dd2eef3eaab8752bf90591c4c@eucas1p1.samsung.com>
2018-03-05  9:06         ` Marek Szyprowski
2018-02-15 21:01   ` Heiko Stübner
2018-03-12  5:54     ` Michael Turquette
2018-02-14 13:43 ` [PATCH v2 5/8] clk: call the clock init() callback before any other ops callback Jerome Brunet
2018-02-14 13:43 ` [PATCH v2 6/8] clk: fix mux clock documentation Jerome Brunet
2018-02-14 13:43 ` [PATCH v2 7/8] clk: divider: read-only divider can propagate rate change Jerome Brunet
2018-02-19 17:30   ` [v2,7/8] " David Lechner
2018-02-14 13:43 ` Jerome Brunet [this message]
2018-03-11 22:31 ` [PATCH v2 0/8] clk: helpers and fixes Michael Turquette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180214134340.17242-9-jbrunet@baylibre.com \
    --to=jbrunet@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®