linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] A couple of clk fixes
@ 2012-07-18  3:52 Shawn Guo
  2012-07-18  3:52 ` [PATCH v2 1/2] clk: fix clk_get on of_clk_get_by_name return check Shawn Guo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shawn Guo @ 2012-07-18  3:52 UTC (permalink / raw)
  To: linux-arm-kernel

This is v2 of a couple of related clk fixes from myself and Rob. It
has these two patches be a series and has changes correctly partitioned
there.

Rob Herring (1):
  clk: fix compile for OF && !COMMON_CLK

Shawn Guo (1):
  clk: fix clk_get on of_clk_get_by_name return check

 drivers/clk/clkdev.c |    4 ++--
 include/linux/clk.h  |    7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] clk: fix clk_get on of_clk_get_by_name return check
  2012-07-18  3:52 [PATCH v2 0/2] A couple of clk fixes Shawn Guo
@ 2012-07-18  3:52 ` Shawn Guo
  2012-07-18  3:52 ` [PATCH v2 2/2] clk: fix compile for OF && !COMMON_CLK Shawn Guo
  2012-07-18  4:03 ` [PATCH v2 0/2] A couple of clk fixes Turquette, Mike
  2 siblings, 0 replies; 4+ messages in thread
From: Shawn Guo @ 2012-07-18  3:52 UTC (permalink / raw)
  To: linux-arm-kernel

The commit 766e6a4 (clk: add DT clock binding support) plugs device
tree clk lookup of_clk_get_by_name into clk_get, and fall on non-DT
lookup clk_get_sys if DT lookup fails.

The return check on of_clk_get_by_name takes (clk != NULL) as a
successful DT lookup.  But it's not the case.  For any system that
does not define clk lookup in device tree, ERR_PTR(-ENOENT) will be
returned, and consequently, all the client drivers calling clk_get
in their probe functions will fail to probe with error code -ENOENT
returned.

Fix the issue by checking of_clk_get_by_name return with !IS_ERR(clk),
and update of_clk_get and of_clk_get_by_name for !CONFIG_OF build
correspondingly.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Tested-by: Marek Vasut <marex@denx.de>
Tested-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
---
 drivers/clk/clkdev.c |    2 +-
 include/linux/clk.h  |    5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 20649b3..69085e0 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -157,7 +157,7 @@ struct clk *clk_get(struct device *dev, const char *con_id)
 
 	if (dev) {
 		clk = of_clk_get_by_name(dev->of_node, con_id);
-		if (clk && __clk_get(clk))
+		if (!IS_ERR(clk) && __clk_get(clk))
 			return clk;
 	}
 
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 9e9b875..6283e2e 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -12,6 +12,7 @@
 #ifndef __LINUX_CLK_H
 #define __LINUX_CLK_H
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/notifier.h>
 
@@ -370,12 +371,12 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
 #else
 static inline struct clk *of_clk_get(struct device_node *np, int index)
 {
-	return NULL;
+	return ERR_PTR(-ENOENT);
 }
 static inline struct clk *of_clk_get_by_name(struct device_node *np,
 					     const char *name)
 {
-	return NULL;
+	return ERR_PTR(-ENOENT);
 }
 #endif
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] clk: fix compile for OF && !COMMON_CLK
  2012-07-18  3:52 [PATCH v2 0/2] A couple of clk fixes Shawn Guo
  2012-07-18  3:52 ` [PATCH v2 1/2] clk: fix clk_get on of_clk_get_by_name return check Shawn Guo
@ 2012-07-18  3:52 ` Shawn Guo
  2012-07-18  4:03 ` [PATCH v2 0/2] A couple of clk fixes Turquette, Mike
  2 siblings, 0 replies; 4+ messages in thread
From: Shawn Guo @ 2012-07-18  3:52 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

With commit 766e6a4ec602d0c107 (clk: add DT clock binding support),
compiling with OF && !COMMON_CLK is broken.

Reported-by: Alexandre Pereira da Silva <aletes.xgr@gmail.com>
Reported-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 drivers/clk/clkdev.c |    2 +-
 include/linux/clk.h  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 69085e0..d423c9b 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -24,7 +24,7 @@
 static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
 
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
 struct clk *of_clk_get(struct device_node *np, int index)
 {
 	struct of_phandle_args clkspec;
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 6283e2e..f80ebad 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -364,7 +364,7 @@ int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
 struct device_node;
 struct of_phandle_args;
 
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
 struct clk *of_clk_get(struct device_node *np, int index);
 struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
 struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 0/2] A couple of clk fixes
  2012-07-18  3:52 [PATCH v2 0/2] A couple of clk fixes Shawn Guo
  2012-07-18  3:52 ` [PATCH v2 1/2] clk: fix clk_get on of_clk_get_by_name return check Shawn Guo
  2012-07-18  3:52 ` [PATCH v2 2/2] clk: fix compile for OF && !COMMON_CLK Shawn Guo
@ 2012-07-18  4:03 ` Turquette, Mike
  2 siblings, 0 replies; 4+ messages in thread
From: Turquette, Mike @ 2012-07-18  4:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 17, 2012 at 8:52 PM, Shawn Guo <shawn.guo@linaro.org> wrote:
> This is v2 of a couple of related clk fixes from myself and Rob. It
> has these two patches be a series and has changes correctly partitioned
> there.
>

Awesome.  I was actually going to make these "partition" changes
manually tomorrow morning and now I don't have to!

Will apply these and push to clk-next after sleeping.

Regards,
Mike

> Rob Herring (1):
>   clk: fix compile for OF && !COMMON_CLK
>
> Shawn Guo (1):
>   clk: fix clk_get on of_clk_get_by_name return check
>
>  drivers/clk/clkdev.c |    4 ++--
>  include/linux/clk.h  |    7 ++++---
>  2 files changed, 6 insertions(+), 5 deletions(-)
>
> --
> 1.7.4.1
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-18  4:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-18  3:52 [PATCH v2 0/2] A couple of clk fixes Shawn Guo
2012-07-18  3:52 ` [PATCH v2 1/2] clk: fix clk_get on of_clk_get_by_name return check Shawn Guo
2012-07-18  3:52 ` [PATCH v2 2/2] clk: fix compile for OF && !COMMON_CLK Shawn Guo
2012-07-18  4:03 ` [PATCH v2 0/2] A couple of clk fixes Turquette, Mike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).