devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] OF: make of_property_for_each_u32() use parameters if OF is not enabled
@ 2013-06-13 15:28 Sebastian Andrzej Siewior
       [not found] ` <1371137331-4652-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2013-06-13 15:28 UTC (permalink / raw)
  To: Grant Likely
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Sebastian Andrzej Siewior, Rob Herring

I am getting a few
|warning: unused variable ‘p’ [-Wunused-variable]
|warning: unused variable ‘prop’ [-Wunused-variable]

in the case where CONFIG_OF is not defined and the parameters are only
used in the loop macro.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/of.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/of.h b/include/linux/of.h
index 1fd08ca..5a89f3f 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -507,8 +507,8 @@ static inline int of_machine_is_compatible(const char *compat)
 
 #define of_match_ptr(_ptr)	NULL
 #define of_match_node(_matches, _node)	NULL
-#define of_property_for_each_u32(np, propname, prop, p, u) \
-	while (0)
+#define of_property_for_each_u32(np, propname, prop, p, u)	\
+	for (prop = NULL, p = NULL; 0; prop++, p++)
 #define of_property_for_each_string(np, propname, prop, s) \
 	while (0)
 #endif /* CONFIG_OF */
-- 
1.7.10.4

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [RFC] OF: make of_property_for_each_u32() use parameters if OF is not enabled
       [not found] ` <1371137331-4652-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
@ 2013-06-15 14:00   ` Grant Likely
  2013-06-17  6:59     ` Sebastian Andrzej Siewior
  2013-06-17 14:48     ` [PATCH v2] OF: make of_property_for_each_{u32|string}() " Sebastian Andrzej Siewior
  0 siblings, 2 replies; 5+ messages in thread
From: Grant Likely @ 2013-06-15 14:00 UTC (permalink / raw)
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Sebastian Andrzej Siewior, Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]

On Thu, 13 Jun 2013 17:28:51 +0200, Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> wrote:
> I am getting a few
> |warning: unused variable ‘p’ [-Wunused-variable]
> |warning: unused variable ‘prop’ [-Wunused-variable]
> 
> in the case where CONFIG_OF is not defined and the parameters are only
> used in the loop macro.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> ---
>  include/linux/of.h |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 1fd08ca..5a89f3f 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -507,8 +507,8 @@ static inline int of_machine_is_compatible(const char *compat)
>  
>  #define of_match_ptr(_ptr)	NULL
>  #define of_match_node(_matches, _node)	NULL
> -#define of_property_for_each_u32(np, propname, prop, p, u) \
> -	while (0)
> +#define of_property_for_each_u32(np, propname, prop, p, u)	\

Unrelated whitespace change

> +	for (prop = NULL, p = NULL; 0; prop++, p++)

The prop++ and p++ bits should be dropped. It would probably be better
to move the of_property_for_each_* macros outside the #ifdef/#else block
and have an empty definition of of_prop_next_string/of_prop_next_u32.

g.


[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [RFC] OF: make of_property_for_each_u32() use parameters if OF is not enabled
  2013-06-15 14:00   ` Grant Likely
@ 2013-06-17  6:59     ` Sebastian Andrzej Siewior
  2013-06-17 14:48     ` [PATCH v2] OF: make of_property_for_each_{u32|string}() " Sebastian Andrzej Siewior
  1 sibling, 0 replies; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2013-06-17  6:59 UTC (permalink / raw)
  To: Grant Likely; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Rob Herring

On 06/15/2013 04:00 PM, Grant Likely wrote:
>> --- a/include/linux/of.h
>> +++ b/include/linux/of.h
>> @@ -507,8 +507,8 @@ static inline int of_machine_is_compatible(const char *compat)
>>  
>>  #define of_match_ptr(_ptr)	NULL
>>  #define of_match_node(_matches, _node)	NULL
>> -#define of_property_for_each_u32(np, propname, prop, p, u) \
>> -	while (0)
>> +#define of_property_for_each_u32(np, propname, prop, p, u)	\
> 
> Unrelated whitespace change
> 
>> +	for (prop = NULL, p = NULL; 0; prop++, p++)
> 
> The prop++ and p++ bits should be dropped. It would probably be better

The ++ ensure that gcc does spit a "set but not used warning".

> to move the of_property_for_each_* macros outside the #ifdef/#else block
> and have an empty definition of of_prop_next_string/of_prop_next_u32.

so let me look at that.

> 
> g.
> 

Sebastian

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

* [PATCH v2] OF: make of_property_for_each_{u32|string}() use parameters if OF is not enabled
  2013-06-15 14:00   ` Grant Likely
  2013-06-17  6:59     ` Sebastian Andrzej Siewior
@ 2013-06-17 14:48     ` Sebastian Andrzej Siewior
       [not found]       ` <20130617144813.GA10582-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2013-06-17 14:48 UTC (permalink / raw)
  To: Grant Likely; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Rob Herring

I am getting a few
|warning: unused variable ‘p’ [-Wunused-variable]
|warning: unused variable ‘prop’ [-Wunused-variable]

in the case where CONFIG_OF is not defined and the parameters are only
used in the loop macro.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---

I also made that change for of_property_for_each_string().

 include/linux/of.h | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/include/linux/of.h b/include/linux/of.h
index 1fd08ca..90a8811 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -323,12 +323,6 @@ extern int of_detach_node(struct device_node *);
  */
 const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
 			       u32 *pu);
-#define of_property_for_each_u32(np, propname, prop, p, u)	\
-	for (prop = of_find_property(np, propname, NULL),	\
-		p = of_prop_next_u32(prop, NULL, &u);		\
-		p;						\
-		p = of_prop_next_u32(prop, p, &u))
-
 /*
  * struct property *prop;
  * const char *s;
@@ -337,11 +331,6 @@ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
  *         printk("String value: %s\n", s);
  */
 const char *of_prop_next_string(struct property *prop, const char *cur);
-#define of_property_for_each_string(np, propname, prop, s)	\
-	for (prop = of_find_property(np, propname, NULL),	\
-		s = of_prop_next_string(prop, NULL);		\
-		s;						\
-		s = of_prop_next_string(prop, s))
 
 #else /* CONFIG_OF */
 
@@ -505,12 +494,20 @@ static inline int of_machine_is_compatible(const char *compat)
 	return 0;
 }
 
+static inline const __be32 *of_prop_next_u32(struct property *prop,
+		const __be32 *cur, u32 *pu)
+{
+	return NULL;
+}
+
+static inline const char *of_prop_next_string(struct property *prop,
+		const char *cur)
+{
+	return NULL;
+}
+
 #define of_match_ptr(_ptr)	NULL
 #define of_match_node(_matches, _node)	NULL
-#define of_property_for_each_u32(np, propname, prop, p, u) \
-	while (0)
-#define of_property_for_each_string(np, propname, prop, s) \
-	while (0)
 #endif /* CONFIG_OF */
 
 #ifndef of_node_to_nid
@@ -559,6 +556,18 @@ static inline int of_property_read_u32(const struct device_node *np,
 	return of_property_read_u32_array(np, propname, out_value, 1);
 }
 
+#define of_property_for_each_u32(np, propname, prop, p, u)	\
+	for (prop = of_find_property(np, propname, NULL),	\
+		p = of_prop_next_u32(prop, NULL, &u);		\
+		p;						\
+		p = of_prop_next_u32(prop, p, &u))
+
+#define of_property_for_each_string(np, propname, prop, s)	\
+	for (prop = of_find_property(np, propname, NULL),	\
+		s = of_prop_next_string(prop, NULL);		\
+		s;						\
+		s = of_prop_next_string(prop, s))
+
 #if defined(CONFIG_PROC_FS) && defined(CONFIG_PROC_DEVICETREE)
 extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
 extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop);
-- 
1.8.3.1

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [PATCH v2] OF: make of_property_for_each_{u32|string}() use parameters if OF is not enabled
       [not found]       ` <20130617144813.GA10582-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
@ 2013-07-20  5:28         ` Grant Likely
  0 siblings, 0 replies; 5+ messages in thread
From: Grant Likely @ 2013-07-20  5:28 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Rob Herring

[-- Attachment #1: Type: text/plain, Size: 3298 bytes --]

On Mon, 17 Jun 2013 16:48:13 +0200, Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> wrote:
> I am getting a few
> |warning: unused variable ‘p’ [-Wunused-variable]
> |warning: unused variable ‘prop’ [-Wunused-variable]
> 
> in the case where CONFIG_OF is not defined and the parameters are only
> used in the loop macro.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>

Applied, thanks

g.


> ---
> 
> I also made that change for of_property_for_each_string().
> 
>  include/linux/of.h | 39 ++++++++++++++++++++++++---------------
>  1 file changed, 24 insertions(+), 15 deletions(-)
> 
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 1fd08ca..90a8811 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -323,12 +323,6 @@ extern int of_detach_node(struct device_node *);
>   */
>  const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
>  			       u32 *pu);
> -#define of_property_for_each_u32(np, propname, prop, p, u)	\
> -	for (prop = of_find_property(np, propname, NULL),	\
> -		p = of_prop_next_u32(prop, NULL, &u);		\
> -		p;						\
> -		p = of_prop_next_u32(prop, p, &u))
> -
>  /*
>   * struct property *prop;
>   * const char *s;
> @@ -337,11 +331,6 @@ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
>   *         printk("String value: %s\n", s);
>   */
>  const char *of_prop_next_string(struct property *prop, const char *cur);
> -#define of_property_for_each_string(np, propname, prop, s)	\
> -	for (prop = of_find_property(np, propname, NULL),	\
> -		s = of_prop_next_string(prop, NULL);		\
> -		s;						\
> -		s = of_prop_next_string(prop, s))
>  
>  #else /* CONFIG_OF */
>  
> @@ -505,12 +494,20 @@ static inline int of_machine_is_compatible(const char *compat)
>  	return 0;
>  }
>  
> +static inline const __be32 *of_prop_next_u32(struct property *prop,
> +		const __be32 *cur, u32 *pu)
> +{
> +	return NULL;
> +}
> +
> +static inline const char *of_prop_next_string(struct property *prop,
> +		const char *cur)
> +{
> +	return NULL;
> +}
> +
>  #define of_match_ptr(_ptr)	NULL
>  #define of_match_node(_matches, _node)	NULL
> -#define of_property_for_each_u32(np, propname, prop, p, u) \
> -	while (0)
> -#define of_property_for_each_string(np, propname, prop, s) \
> -	while (0)
>  #endif /* CONFIG_OF */
>  
>  #ifndef of_node_to_nid
> @@ -559,6 +556,18 @@ static inline int of_property_read_u32(const struct device_node *np,
>  	return of_property_read_u32_array(np, propname, out_value, 1);
>  }
>  
> +#define of_property_for_each_u32(np, propname, prop, p, u)	\
> +	for (prop = of_find_property(np, propname, NULL),	\
> +		p = of_prop_next_u32(prop, NULL, &u);		\
> +		p;						\
> +		p = of_prop_next_u32(prop, p, &u))
> +
> +#define of_property_for_each_string(np, propname, prop, s)	\
> +	for (prop = of_find_property(np, propname, NULL),	\
> +		s = of_prop_next_string(prop, NULL);		\
> +		s;						\
> +		s = of_prop_next_string(prop, s))
> +
>  #if defined(CONFIG_PROC_FS) && defined(CONFIG_PROC_DEVICETREE)
>  extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
>  extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop);
> -- 
> 1.8.3.1
> 


[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

end of thread, other threads:[~2013-07-20  5:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13 15:28 [RFC] OF: make of_property_for_each_u32() use parameters if OF is not enabled Sebastian Andrzej Siewior
     [not found] ` <1371137331-4652-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-06-15 14:00   ` Grant Likely
2013-06-17  6:59     ` Sebastian Andrzej Siewior
2013-06-17 14:48     ` [PATCH v2] OF: make of_property_for_each_{u32|string}() " Sebastian Andrzej Siewior
     [not found]       ` <20130617144813.GA10582-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-07-20  5:28         ` Grant Likely

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).