* [PATCH] clk: fix clk_get on of_clk_get_by_name return check
@ 2012-07-15 14:09 Shawn Guo
2012-07-15 15:10 ` Rob Herring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Shawn Guo @ 2012-07-15 14:09 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).
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/clk/clkdev.c | 2 +-
1 files changed, 1 insertions(+), 1 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;
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] clk: fix clk_get on of_clk_get_by_name return check
2012-07-15 14:09 [PATCH] clk: fix clk_get on of_clk_get_by_name return check Shawn Guo
@ 2012-07-15 15:10 ` Rob Herring
2012-07-15 15:20 ` Marek Vasut
2012-07-17 8:12 ` Lauri Hintsala
2 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2012-07-15 15:10 UTC (permalink / raw)
To: linux-arm-kernel
On 07/15/2012 09:09 AM, Shawn Guo wrote:
> 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).
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Thanks Shawn.
Acked-by: Rob Herring <rob.herring@calxeda.com>
> ---
> drivers/clk/clkdev.c | 2 +-
> 1 files changed, 1 insertions(+), 1 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;
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] clk: fix clk_get on of_clk_get_by_name return check
2012-07-15 14:09 [PATCH] clk: fix clk_get on of_clk_get_by_name return check Shawn Guo
2012-07-15 15:10 ` Rob Herring
@ 2012-07-15 15:20 ` Marek Vasut
2012-07-17 8:12 ` Lauri Hintsala
2 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2012-07-15 15:20 UTC (permalink / raw)
To: linux-arm-kernel
Dear Shawn Guo,
> 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).
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Tested-by: Marek Vasut <marex@denx.de>
> ---
> drivers/clk/clkdev.c | 2 +-
> 1 files changed, 1 insertions(+), 1 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;
> }
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] clk: fix clk_get on of_clk_get_by_name return check
2012-07-15 14:09 [PATCH] clk: fix clk_get on of_clk_get_by_name return check Shawn Guo
2012-07-15 15:10 ` Rob Herring
2012-07-15 15:20 ` Marek Vasut
@ 2012-07-17 8:12 ` Lauri Hintsala
2 siblings, 0 replies; 4+ messages in thread
From: Lauri Hintsala @ 2012-07-17 8:12 UTC (permalink / raw)
To: linux-arm-kernel
This patch fixes the boot issue on mx28evk and apx4devkit.
On 07/15/2012 05:09 PM, Shawn Guo wrote:
> 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).
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Tested-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
Best regards,
Lauri Hintsala
> ---
> drivers/clk/clkdev.c | 2 +-
> 1 files changed, 1 insertions(+), 1 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;
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-17 8:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-15 14:09 [PATCH] clk: fix clk_get on of_clk_get_by_name return check Shawn Guo
2012-07-15 15:10 ` Rob Herring
2012-07-15 15:20 ` Marek Vasut
2012-07-17 8:12 ` Lauri Hintsala
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).