Thread (1 message) 1 message, 1 author, 2011-08-04

Re: Virtual devices (cpufreq etc) and DT

From: Jamie Iles <hidden>
Date: 2011-08-04 10:23:21
Subsystem: arm/clkdev support, the rest · Maintainers: Russell King, Linus Torvalds

Possibly related (same subject, not in this thread)

Hi Rob,

On Wed, Aug 03, 2011 at 11:29:16AM -0500, Rob Herring wrote:
[...]
quoted hunk
Making of_clk_get take a struct device_node ptr instead of struct 
device fixes the problem. Here's a patch that does that.

Rob

From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH] of/clk: use struct device_node for of_clk_get

In order to allow clock retrieval without having a struct device,
use the OF node pointer instead for of_clk_get.

Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
---
 drivers/clk/clkdev.c   |    3 ++-
 drivers/of/clock.c     |   12 +++++-------
 include/linux/of_clk.h |    4 ++--
 3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 9252b4f..a8f1d29 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -89,7 +89,8 @@ struct clk *clk_get(struct device *dev, const char
*con_id)
 	const char *dev_id = dev ? dev_name(dev) : NULL;
 	struct clk *clk;

-	clk = of_clk_get(dev, con_id);
+	if (dev)
+		clk = of_clk_get(dev->of_node, con_id);
 	if (clk && __clk_get(clk))
 		return clk;
I've just tried this patch and it works a treat, but I had to change 
this hunk to the one below to stop the compiler warning about a possible 
uninitialized use of clk.

Jamie
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index f2b1224..bc5ae55 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -80,9 +80,10 @@ EXPORT_SYMBOL(clk_get_sys);
 struct clk *clk_get(struct device *dev, const char *con_id)
 {
 	const char *dev_id = dev ? dev_name(dev) : NULL;
-	struct clk *clk;
+	struct clk *clk = NULL;
 
-	clk = of_clk_get(dev, con_id);
+	if (dev->of_node)
+		clk = of_clk_get(dev->of_node, con_id);
 	if (clk && __clk_get(clk))
		return clk;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help