All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org
Subject: [PATCH 7/8] clk: Document and simplify clk_core_get_rate_nolock()
Date: Tue,  2 Apr 2019 16:01:03 -0700	[thread overview]
Message-ID: <20190402230104.105845-8-sboyd@kernel.org> (raw)
In-Reply-To: <20190402230104.105845-1-sboyd@kernel.org>

This function uses a few gotos and doesn't explain why parents and
numbers of parents are being checked before returning different values
for the clk's rate. Document and simplify this function somewhat to make
this better.

Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
 drivers/clk/clk.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index c9860074899b..79d0466cd180 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -345,23 +345,18 @@ unsigned int __clk_get_enable_count(struct clk *clk)
 
 static unsigned long clk_core_get_rate_nolock(struct clk_core *core)
 {
-	unsigned long ret;
-
-	if (!core) {
-		ret = 0;
-		goto out;
-	}
-
-	ret = core->rate;
-
-	if (!core->num_parents)
-		goto out;
+	if (!core)
+		return 0;
 
-	if (!core->parent)
-		ret = 0;
+	if (!core->num_parents || core->parent)
+		return core->rate;
 
-out:
-	return ret;
+	/*
+	 * Clk must have a parent because num_parents > 0 but the parent isn't
+	 * known yet. Best to return 0 as the rate of this clk until we can
+	 * properly recalc the rate based on the parent's rate.
+	 */
+	return 0;
 }
 
 unsigned long clk_hw_get_rate(const struct clk_hw *hw)
-- 
Sent by a computer through tubes


  parent reply	other threads:[~2019-04-02 23:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02 23:00 [PATCH 0/8] Clk documentation updates Stephen Boyd
2019-04-02 23:00 ` [PATCH 1/8] clk: Collapse gpio clk kerneldoc Stephen Boyd
2019-04-02 23:00 ` [PATCH 2/8] clk: Document deprecated things Stephen Boyd
2019-04-02 23:00 ` [PATCH 3/8] clk: Document CLK_MUX_READ_ONLY mux flag Stephen Boyd
2019-04-02 23:01 ` [PATCH 4/8] clk: Document __clk_mux_determine_rate() Stephen Boyd
2019-04-02 23:01 ` [PATCH 5/8] clk: nxp: Drop 'flags' on fixed_rate clk macro Stephen Boyd
2019-04-02 23:01 ` [PATCH 6/8] clk: Remove 'flags' member of struct clk_fixed_rate Stephen Boyd
2019-04-02 23:01 ` Stephen Boyd [this message]
2019-04-02 23:01 ` [PATCH 8/8] clk: Drop duplicate clk_register() documentation Stephen Boyd

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=20190402230104.105845-8-sboyd@kernel.org \
    --to=sboyd@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.