clk: fix compile for OF && !COMMON_CLK
Subsystems (2)
PATCH 1/1 clk: fix compile for OF && !COMMON_CLK
From: Rob Herring <[email protected]>
With commit 766e6a4ec602d0c107 (clk: add DT clock binding support), compiling with OF && !COMMON_CLK is broken.
--- drivers/clk/clkdev.c | 2 +- include/linux/clk.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/clk/clkdev.c +1 -1
@@ -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;
include/linux/clk.h +4 -3
@@ -12,6 +12,7 @@#ifndef __LINUX_CLK_H#define __LINUX_CLK_H +#include <linux/err.h> #include <linux/kernel.h> #include <linux/notifier.h>
@@ -313,19 +314,19 @@ 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);#else static inline struct clk *of_clk_get (struct device_node *np,int index) { -return NULL ; +return ERR_PTR (-EINVAL ); }static inline struct clk *of_clk_get_by_name (struct device_node *np,const char *name) { -return NULL ; +return ERR_PTR (-EINVAL ); }#endif
Signature · 1 line
1.7.9.5
Quoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
With commit
766e6a4ec602d0c107(clk: add DT clock binding support), compiling with OF && !COMMON_CLK is broken.
Hi Rob,
Thanks for sending this quickly.
<snip>
Quoted 4 lines
include/linux/clk.h +0
-0@@ -313,19 +314,19 @@ int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,struct device_node ;struct of_phandle_args ;
include/linux/clk.h int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, · line 324
Quoted 10 lines
include/linux/clk.h +2
-2-#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);#else static inline struct clk *of_clk_get (struct device_node *np,int index) { -return NULL ; +return ERR_PTR (-EINVAL );
This change seems unrelated?
include/linux/clk.h int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, · line 329
Quoted 6 lines
include/linux/clk.h +1
-1}static inline struct clk *of_clk_get_by_name (struct device_node *np,const char *name) { -return NULL ; +return ERR_PTR (-EINVAL );
Ditto.
Thanks,
Mike
Quoted 6 lines
(quoted diff) +0
-0} #endifSignature · 1 line
1.7.9.5
Quoted 4 lines · Rob Herring
From: Rob Herring <[email protected]>
With commit
766e6a4ec602d0c107(clk: add DT clock binding support), compiling with OF && !COMMON_CLK is broken.
Thanks, Rob.
This fixed the issue for me, but Mike's comments applies.
Quoted 59 lines
Reported-by Alexandre Pereira da Silva <[email protected]>Reported-by Prashant Gaikwad <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/clk/clkdev.c | 2 +- include/linux/clk.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)drivers/clk/clkdev.c +1
-1@@ -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;include/linux/clk.h +4
-4@@ -12,6 +12,7 @@#ifndef __LINUX_CLK_H#define __LINUX_CLK_H +#include <linux/err.h> #include <linux/kernel.h> #include <linux/notifier.h> @@ -313,19 +314,19 @@ 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);#else static inline struct clk *of_clk_get (struct device_node *np,int index) { -return NULL ; +return ERR_PTR (-EINVAL ); }static inline struct clk *of_clk_get_by_name (struct device_node *np,const char *name) { -return NULL ; +return ERR_PTR (-EINVAL ); }#endif --1.7.9.5
Quoted 29 lines · Mike Turquette
Quoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
With commit
766e6a4ec602d0c107(clk: add DT clock binding support), compiling with OF && !COMMON_CLK is broken.Hi Rob,
Thanks for sending this quickly.
<snip>
Quoted 4 lines
include/linux/clk.h +0
-0@@ -313,19 +314,19 @@ int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,struct device_node ;struct of_phandle_args ;include/linux/clk.h int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, · line 324
Quoted 10 lines
include/linux/clk.h +2
-2-#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);#else static inline struct clk *of_clk_get (struct device_node *np,int index) { -return NULL ; +return ERR_PTR (-EINVAL );This change seems unrelated?
Quoted 8 lines
include/linux/clk.h int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, · line 329
Quoted 6 lines
include/linux/clk.h +1
-1}static inline struct clk *of_clk_get_by_name (struct device_node *np,const char *name) { -return NULL ; +return ERR_PTR (-EINVAL );Ditto.
Yeah, it should probably go in Shawn's fix as that is actually when it will start breaking.
Rob
Quoted 10 lines
Thanks,
MikeQuoted 6 lines
(quoted diff) +0
-0} #endifSignature · 1 line
1.7.9.5
Quoted 4 lines · Rob Herring
From: Rob Herring<[email protected]>
With commit
766e6a4ec602d0c107(clk: add DT clock binding support), compiling with OF&& !COMMON_CLK is broken.
Thanks Rob!!
This patch fixed the build failure for Tegra.
Quoted 56 lines
Reported-by Alexandre Pereira da Silva<[email protected]>Reported-by Prashant Gaikwad<[email protected]>Signed-off-by Rob Herring<[email protected]>--- drivers/clk/clkdev.c | 2 +- include/linux/clk.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)drivers/clk/clkdev.c +1
-1@@ -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;include/linux/clk.h +4
-3@@ -12,6 +12,7 @@#ifndef __LINUX_CLK_H#define __LINUX_CLK_H +#include <linux/err.h> #include <linux/kernel.h> #include <linux/notifier.h> @@ -313,19 +314,19 @@ 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);#else static inline struct clk *of_clk_get (struct device_node *np,int index) { -return NULL ; +return ERR_PTR (-EINVAL ); }static inline struct clk *of_clk_get_by_name (struct device_node *np,const char *name) { -return NULL ; +return ERR_PTR (-EINVAL ); }#endif
Rob, Mike,
Quoted 17 lines · Rob Herring
Quoted 16 lines · Mike Turquette
Quoted 5 lines · Rob Herring
From: Rob Herring<[email protected]>
With commit
766e6a4ec602d0c107(clk: add DT clock binding support), compiling with OF&& !COMMON_CLK is broken.Hi Rob,
Thanks for sending this quickly.
<snip>
Quoted 4 lines
include/linux/clk.h +0
-0@@ -313,19 +314,19 @@ int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,struct device_node ;struct of_phandle_args ;
Quoted 10 lines
Quoted 10 lines
include/linux/clk.h int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, · line 324
Quoted 10 lines
include/linux/clk.h +2
-2-#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);#else static inline struct clk *of_clk_get (struct device_node *np,int index) { -return NULL ; +return ERR_PTR (-EINVAL );
So how is this expected to work on platforms (like OMAP) which have CONFIG_OF enabled but not CONFIG_COMMON_CLK?
Archit has been seeing issues with failed clk_get's in the omap dss driver on linux-next.
The clk_gets pass a valid dev pointer and an alias/con-id.
With the $Subject patch, the of_clk_get_by_name() for our builds always returns a ERR_PTR(-EINVAL).
Even if we do get the right of_clk_get_by_name() built in, there is another issue on OMAP where in we have CONFIG_OF enabled/selected by default for all OMAP2+ builds, even when we *do not* pass a dt blob to the kernel.
So would the below code fail in such cases because it expects a valid of_node to be populated for a device (which also has clock information in it)? if CONFIG_OF is set.
struct clk *clk_get(struct device *dev, const char *con_id)
{
const char *dev_id = dev ? dev_name(dev) : NULL;
struct clk *clk;
if (dev) {
---->
Any reason why this isn't
if (dev->of_node) {
---->
clk = of_clk_get_by_name(dev->of_node, con_id);
if (clk && __clk_get(clk))
return clk;
}
return clk_get_sys(dev_id, con_id);
}regards,
Rajendra
Quoted 10 lines · Rajendra Nayak
struct clk *clk_get(struct device *dev, const char
*con_id){ const char *dev_id = dev ? dev_name(dev) : NULL; struct clk *clk; if (dev) {---->
Any reason why this isn't
if (dev->of_node) {
---->
Or rather,
if (dev && dev->of_node) {as Archit just pointed out to me.
Quoted 21 lines · Rajendra Nayak
Rob, Mike,
Quoted 18 lines · Rob Herring
Quoted 17 lines · Mike Turquette
Quoted 5 lines · Rob Herring
From: Rob Herring<[email protected]>
With commit
766e6a4ec602d0c107(clk: add DT clock binding support), compiling with OF&& !COMMON_CLK is broken.Hi Rob,
Thanks for sending this quickly.
<snip>
Quoted 5 lines
include/linux/clk.h +0
-0@@ -313,19 +314,19 @@ int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, struct device_node;struct of_phandle_args ;
Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
(quoted diff) +1
-1-#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);Quoted 8 lines
Quoted 8 lines
include/linux/clk.h int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, · line 324
Quoted 8 lines
include/linux/clk.h +1
-1struct 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 (-EINVAL );So how is this expected to work on platforms (like OMAP) which have
CONFIG_OFenabled but notCONFIG_COMMON_CLK?
As I mentioned in my other reply, this really belongs with Shawn's patch that changes the return value checking from NULL to err values.
Quoted 22 lines
Archit has been seeing issues with failed clk_get's in the omap dss driver on linux-next.
Theclk_getspass a valid dev pointer and an alias/con-id.With the $Subject patch, the
of_clk_get_by_name()for our builds always returns aERR_PTR(-EINVAL).Even if we do get the right
of_clk_get_by_name()built in, there is another issue on OMAP where in we haveCONFIG_OFenabled/selected by default for all OMAP2+ builds, even when we *do not* pass a dt blob to the kernel.So would the below code fail in such cases because it expects a valid
of_nodeto be populated for a device (which also has clock information in it)? ifCONFIG_OFis set.struct clk *clk_get(struct device *dev, const char
*con_id){ const char *dev_id = dev ? dev_name(dev) : NULL; struct clk *clk; if (dev) {
Quoted 4 lines
---->
Any reason why this isn't
if (dev->of_node) {
---->
dev may be null, we could do (dev && dev->of_node) though. Either way the error handling here needs to do the right thing.
Quoted 15 lines
clk = of_clk_get_by_name(dev->of_node, con_id); if (clk && __clk_get(clk)) return clk; } return clk_get_sys(dev_id, con_id); }regards,
Rajendra
Quoted 6 lines · Rob Herring
Quoted 3 lines
So how is this expected to work on platforms (like OMAP) which have
Quoted 2 lines
CONFIG_OFenabled but notCONFIG_COMMON_CLK?As I mentioned in my other reply, this really belongs with Shawn's patch that changes the return value checking from NULL to err values.
ah, I seemed to have missed that. Just had a look at Shawn's patch and that should work for OMAP too. thanks.