]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
clk: fix clk_get on of_clk_get_by_name return check
authorShawn Guo <shawn.guo@linaro.org>
Wed, 18 Jul 2012 03:52:22 +0000 (11:52 +0800)
committerMike Turquette <mturquette@linaro.org>
Thu, 19 Jul 2012 21:07:45 +0000 (14:07 -0700)
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>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
drivers/clk/clkdev.c
include/linux/clk.h

index 20649b3c88fe4bca95f6b39506db76fc5c733eb9..69085e02bd58f3ea067ef45af84f0e6be08e16f0 100644 (file)
@@ -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;
        }
 
index 8b70342e7e0b74f8c4444903a4fd1bfb777cd518..071e24083dc8448f0d50b663f7fc2ac989308181 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef __LINUX_CLK_H
 #define __LINUX_CLK_H
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/notifier.h>
 
@@ -320,12 +321,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