aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@kernel.org>2019-04-12 14:31:43 -0400
committerStephen Boyd <sboyd@kernel.org>2019-04-19 17:24:23 -0400
commitd1011cba02f2f931f0a95ea093cb25bc7738ff4d (patch)
treedefe645938e75d474513d94273c2dcb37df6188d
parent5a7efdacb9dda1c35fb414d57b3e16d520e2c0db (diff)
clkdev: Move clk creation outside of 'clocks_mutex'
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> Tested-by: Jeffrey Hugo <jhugo@codeaurora.org> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
-rw-r--r--drivers/clk/clkdev.c25
1 files 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)
72 return cl; 72 return cl;
73} 73}
74 74
75static struct clk *__clk_get_sys(struct device *dev, const char *dev_id, 75static struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id)
76 const char *con_id)
77{ 76{
78 struct clk_lookup *cl; 77 struct clk_lookup *cl;
79 struct clk *clk = NULL; 78 struct clk_hw *hw = ERR_PTR(-ENOENT);
80 79
81 mutex_lock(&clocks_mutex); 80 mutex_lock(&clocks_mutex);
82
83 cl = clk_find(dev_id, con_id); 81 cl = clk_find(dev_id, con_id);
84 if (!cl) 82 if (cl)
85 goto out; 83 hw = cl->clk_hw;
86
87 clk = clk_hw_create_clk(dev, cl->clk_hw, dev_id, con_id);
88 if (IS_ERR(clk))
89 cl = NULL;
90out:
91 mutex_unlock(&clocks_mutex); 84 mutex_unlock(&clocks_mutex);
92 85
93 return cl ? clk : ERR_PTR(-ENOENT); 86 return hw;
87}
88
89static struct clk *__clk_get_sys(struct device *dev, const char *dev_id,
90 const char *con_id)
91{
92 struct clk_hw *hw = clk_find_hw(dev_id, con_id);
93
94 return clk_hw_create_clk(dev, hw, dev_id, con_id);
94} 95}
95 96
96struct clk *clk_get_sys(const char *dev_id, const char *con_id) 97struct clk *clk_get_sys(const char *dev_id, const char *con_id)