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,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Russell King <linux@armlinux.org.uk>,
	Jeffrey Hugo <jhugo@codeaurora.org>, Chen-Yu Tsai <wens@csie.org>
Subject: [PATCH v4 2/9] clkdev: Move clk creation outside of 'clocks_mutex'
Date: Fri, 12 Apr 2019 11:31:43 -0700	[thread overview]
Message-ID: <20190412183150.102131-3-sboyd@kernel.org> (raw)
In-Reply-To: <20190412183150.102131-1-sboyd@kernel.org>

We don't need to hold the 'clocks_mutex' here when we're creating a clk
pointer from a clk_lookup structure. Instead, we just need to make sure
that the lookup doesn't go away while we dereference the lookup pointer
to extract the clk_hw pointer out of it. Let's move things around
slightly so that we have a new function to get the clk_hw out of the
lookup with the right locking and then chain the two together for what
used to be __clk_get_sys().

Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Jeffrey Hugo <jhugo@codeaurora.org>
Cc: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
 drivers/clk/clkdev.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 6e787cc9e5b9..6f65bde696da 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -72,25 +72,26 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
 	return cl;
 }
 
-static struct clk *__clk_get_sys(struct device *dev, const char *dev_id,
-				 const char *con_id)
+static struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id)
 {
 	struct clk_lookup *cl;
-	struct clk *clk = NULL;
+	struct clk_hw *hw = ERR_PTR(-ENOENT);
 
 	mutex_lock(&clocks_mutex);
-
 	cl = clk_find(dev_id, con_id);
-	if (!cl)
-		goto out;
-
-	clk = clk_hw_create_clk(dev, cl->clk_hw, dev_id, con_id);
-	if (IS_ERR(clk))
-		cl = NULL;
-out:
+	if (cl)
+		hw = cl->clk_hw;
 	mutex_unlock(&clocks_mutex);
 
-	return cl ? clk : ERR_PTR(-ENOENT);
+	return hw;
+}
+
+static struct clk *__clk_get_sys(struct device *dev, const char *dev_id,
+				 const char *con_id)
+{
+	struct clk_hw *hw = clk_find_hw(dev_id, con_id);
+
+	return clk_hw_create_clk(dev, hw, dev_id, con_id);
 }
 
 struct clk *clk_get_sys(const char *dev_id, const char *con_id)
-- 
Sent by a computer through tubes


  parent reply	other threads:[~2019-04-12 18:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-12 18:31 [PATCH v4 0/9] Rewrite clk parent handling Stephen Boyd
2019-04-12 18:31 ` [PATCH v4 1/9] clkdev: Hold clocks_mutex while iterating clocks list Stephen Boyd
2019-04-15  5:22   ` Matti Vaittinen
2019-04-18 20:34   ` Stephen Boyd
2019-04-12 18:31 ` Stephen Boyd [this message]
2019-04-19 22:12   ` [PATCH v4 2/9] clkdev: Move clk creation outside of 'clocks_mutex' Stephen Boyd
2019-04-12 18:31 ` [PATCH v4 3/9] clk: Prepare for clk registration API that uses DT nodes Stephen Boyd
2019-04-19 22:12   ` Stephen Boyd
2019-04-12 18:31 ` [PATCH v4 4/9] driver core: Let dev_of_node() accept a NULL dev Stephen Boyd
2019-04-16 13:29   ` Greg Kroah-Hartman
2019-04-19 22:12   ` Stephen Boyd
2019-04-12 18:31 ` [PATCH v4 5/9] clk: Add of_clk_hw_register() API for early clk drivers Stephen Boyd
2019-04-19 22:12   ` Stephen Boyd
2019-04-12 18:31 ` [PATCH v4 6/9] clk: Allow parents to be specified without string names Stephen Boyd
2019-04-19 22:12   ` Stephen Boyd
2019-04-12 18:31 ` [PATCH v4 7/9] clk: Look for parents with clkdev based clk_lookups Stephen Boyd
2019-04-19 22:13   ` Stephen Boyd
2019-04-12 18:31 ` [PATCH v4 8/9] clk: Allow parents to be specified via clkspec index Stephen Boyd
2019-04-19 22:13   ` Stephen Boyd
2019-04-12 18:31 ` [PATCH v4 9/9] clk: fixed-factor: Let clk framework find parent Stephen Boyd
2019-04-19 22:13   ` Stephen Boyd
2019-04-23 18:09   ` Guenter Roeck
2019-04-23 18:22     ` Stephen Boyd
2019-04-23 19:26       ` Guenter Roeck
2019-04-15 18:05 ` [PATCH v4 0/9] Rewrite clk parent handling Jeffrey Hugo

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=20190412183150.102131-3-sboyd@kernel.org \
    --to=sboyd@kernel.org \
    --cc=jbrunet@baylibre.com \
    --cc=jhugo@codeaurora.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=miquel.raynal@bootlin.com \
    --cc=mturquette@baylibre.com \
    --cc=wens@csie.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 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.