aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2014-02-03 09:53:44 -0500
committerRob Herring <robh@kernel.org>2014-02-05 10:51:54 -0500
commit662372e42e46d9bbfcb83e1cce81f6b33cebaddd (patch)
tree3bae78a163360b86e61ecd76208d9611b2c1f777 /include
parentb2d960e4061986c6aab2269103d61e8408dcc71d (diff)
of: restructure for_each macros to fix compile warnings
Commit 00b2c76a6a "include/linux/of.h: make for_each_child_of_node() reference its args when CONFIG_OF=n" fixed warnings for unused variables, but introduced variable "used uninitialized" warnings. Simply initializing the variables would result in "set but not used" warnings with W=1. Fix both types of warnings by making all the for_each macros unconditional and rely on the dummy static inline functions to initialize and reference any variables. Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Cc: David Howells <dhowells@redhat.com> Signed-off-by: Rob Herring <robh@kernel.org> Acked-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/of.h153
1 files changed, 84 insertions, 69 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index 70c64ba17fa5..435cb995904d 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -169,35 +169,15 @@ static inline const char *of_node_full_name(const struct device_node *np)
169 169
170extern struct device_node *of_find_node_by_name(struct device_node *from, 170extern struct device_node *of_find_node_by_name(struct device_node *from,
171 const char *name); 171 const char *name);
172#define for_each_node_by_name(dn, name) \
173 for (dn = of_find_node_by_name(NULL, name); dn; \
174 dn = of_find_node_by_name(dn, name))
175extern struct device_node *of_find_node_by_type(struct device_node *from, 172extern struct device_node *of_find_node_by_type(struct device_node *from,
176 const char *type); 173 const char *type);
177#define for_each_node_by_type(dn, type) \
178 for (dn = of_find_node_by_type(NULL, type); dn; \
179 dn = of_find_node_by_type(dn, type))
180extern struct device_node *of_find_compatible_node(struct device_node *from, 174extern struct device_node *of_find_compatible_node(struct device_node *from,
181 const char *type, const char *compat); 175 const char *type, const char *compat);
182#define for_each_compatible_node(dn, type, compatible) \
183 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
184 dn = of_find_compatible_node(dn, type, compatible))
185extern struct device_node *of_find_matching_node_and_match( 176extern struct device_node *of_find_matching_node_and_match(
186 struct device_node *from, 177 struct device_node *from,
187 const struct of_device_id *matches, 178 const struct of_device_id *matches,
188 const struct of_device_id **match); 179 const struct of_device_id **match);
189static inline struct device_node *of_find_matching_node( 180
190 struct device_node *from,
191 const struct of_device_id *matches)
192{
193 return of_find_matching_node_and_match(from, matches, NULL);
194}
195#define for_each_matching_node(dn, matches) \
196 for (dn = of_find_matching_node(NULL, matches); dn; \
197 dn = of_find_matching_node(dn, matches))
198#define for_each_matching_node_and_match(dn, matches, match) \
199 for (dn = of_find_matching_node_and_match(NULL, matches, match); \
200 dn; dn = of_find_matching_node_and_match(dn, matches, match))
201extern struct device_node *of_find_node_by_path(const char *path); 181extern struct device_node *of_find_node_by_path(const char *path);
202extern struct device_node *of_find_node_by_phandle(phandle handle); 182extern struct device_node *of_find_node_by_phandle(phandle handle);
203extern struct device_node *of_get_parent(const struct device_node *node); 183extern struct device_node *of_get_parent(const struct device_node *node);
@@ -209,43 +189,11 @@ extern struct device_node *of_get_next_available_child(
209 189
210extern struct device_node *of_get_child_by_name(const struct device_node *node, 190extern struct device_node *of_get_child_by_name(const struct device_node *node,
211 const char *name); 191 const char *name);
212#define for_each_child_of_node(parent, child) \
213 for (child = of_get_next_child(parent, NULL); child != NULL; \
214 child = of_get_next_child(parent, child))
215
216#define for_each_available_child_of_node(parent, child) \
217 for (child = of_get_next_available_child(parent, NULL); child != NULL; \
218 child = of_get_next_available_child(parent, child))
219
220static inline int of_get_child_count(const struct device_node *np)
221{
222 struct device_node *child;
223 int num = 0;
224
225 for_each_child_of_node(np, child)
226 num++;
227
228 return num;
229}
230
231static inline int of_get_available_child_count(const struct device_node *np)
232{
233 struct device_node *child;
234 int num = 0;
235
236 for_each_available_child_of_node(np, child)
237 num++;
238
239 return num;
240}
241 192
242/* cache lookup */ 193/* cache lookup */
243extern struct device_node *of_find_next_cache_node(const struct device_node *); 194extern struct device_node *of_find_next_cache_node(const struct device_node *);
244extern struct device_node *of_find_node_with_property( 195extern struct device_node *of_find_node_with_property(
245 struct device_node *from, const char *prop_name); 196 struct device_node *from, const char *prop_name);
246#define for_each_node_with_property(dn, prop_name) \
247 for (dn = of_find_node_with_property(NULL, prop_name); dn; \
248 dn = of_find_node_with_property(dn, prop_name))
249 197
250extern struct property *of_find_property(const struct device_node *np, 198extern struct property *of_find_property(const struct device_node *np,
251 const char *name, 199 const char *name,
@@ -367,42 +315,53 @@ static inline struct device_node *of_find_node_by_name(struct device_node *from,
367 return NULL; 315 return NULL;
368} 316}
369 317
370static inline struct device_node *of_get_parent(const struct device_node *node) 318static inline struct device_node *of_find_node_by_type(struct device_node *from,
319 const char *type)
371{ 320{
372 return NULL; 321 return NULL;
373} 322}
374 323
375static inline bool of_have_populated_dt(void) 324static inline struct device_node *of_find_matching_node_and_match(
325 struct device_node *from,
326 const struct of_device_id *matches,
327 const struct of_device_id **match)
376{ 328{
377 return false; 329 return NULL;
378} 330}
379 331
380/* Kill an unused variable warning on a device_node pointer */ 332static inline struct device_node *of_get_parent(const struct device_node *node)
381static inline void __of_use_dn(const struct device_node *np)
382{ 333{
334 return NULL;
383} 335}
384 336
385#define for_each_child_of_node(parent, child) \ 337static inline struct device_node *of_get_next_child(
386 while (__of_use_dn(parent), __of_use_dn(child), 0) 338 const struct device_node *node, struct device_node *prev)
339{
340 return NULL;
341}
387 342
388#define for_each_available_child_of_node(parent, child) \ 343static inline struct device_node *of_get_next_available_child(
389 while (0) 344 const struct device_node *node, struct device_node *prev)
345{
346 return NULL;
347}
390 348
391static inline struct device_node *of_get_child_by_name( 349static inline struct device_node *of_find_node_with_property(
392 const struct device_node *node, 350 struct device_node *from, const char *prop_name)
393 const char *name)
394{ 351{
395 return NULL; 352 return NULL;
396} 353}
397 354
398static inline int of_get_child_count(const struct device_node *np) 355static inline bool of_have_populated_dt(void)
399{ 356{
400 return 0; 357 return false;
401} 358}
402 359
403static inline int of_get_available_child_count(const struct device_node *np) 360static inline struct device_node *of_get_child_by_name(
361 const struct device_node *node,
362 const char *name)
404{ 363{
405 return 0; 364 return NULL;
406} 365}
407 366
408static inline int of_device_is_compatible(const struct device_node *device, 367static inline int of_device_is_compatible(const struct device_node *device,
@@ -569,6 +528,13 @@ extern int of_node_to_nid(struct device_node *np);
569static inline int of_node_to_nid(struct device_node *device) { return 0; } 528static inline int of_node_to_nid(struct device_node *device) { return 0; }
570#endif 529#endif
571 530
531static inline struct device_node *of_find_matching_node(
532 struct device_node *from,
533 const struct of_device_id *matches)
534{
535 return of_find_matching_node_and_match(from, matches, NULL);
536}
537
572/** 538/**
573 * of_property_read_bool - Findfrom a property 539 * of_property_read_bool - Findfrom a property
574 * @np: device node from which the property value is to be read. 540 * @np: device node from which the property value is to be read.
@@ -618,6 +584,55 @@ static inline int of_property_read_u32(const struct device_node *np,
618 s; \ 584 s; \
619 s = of_prop_next_string(prop, s)) 585 s = of_prop_next_string(prop, s))
620 586
587#define for_each_node_by_name(dn, name) \
588 for (dn = of_find_node_by_name(NULL, name); dn; \
589 dn = of_find_node_by_name(dn, name))
590#define for_each_node_by_type(dn, type) \
591 for (dn = of_find_node_by_type(NULL, type); dn; \
592 dn = of_find_node_by_type(dn, type))
593#define for_each_compatible_node(dn, type, compatible) \
594 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
595 dn = of_find_compatible_node(dn, type, compatible))
596#define for_each_matching_node(dn, matches) \
597 for (dn = of_find_matching_node(NULL, matches); dn; \
598 dn = of_find_matching_node(dn, matches))
599#define for_each_matching_node_and_match(dn, matches, match) \
600 for (dn = of_find_matching_node_and_match(NULL, matches, match); \
601 dn; dn = of_find_matching_node_and_match(dn, matches, match))
602
603#define for_each_child_of_node(parent, child) \
604 for (child = of_get_next_child(parent, NULL); child != NULL; \
605 child = of_get_next_child(parent, child))
606#define for_each_available_child_of_node(parent, child) \
607 for (child = of_get_next_available_child(parent, NULL); child != NULL; \
608 child = of_get_next_available_child(parent, child))
609
610#define for_each_node_with_property(dn, prop_name) \
611 for (dn = of_find_node_with_property(NULL, prop_name); dn; \
612 dn = of_find_node_with_property(dn, prop_name))
613
614static inline int of_get_child_count(const struct device_node *np)
615{
616 struct device_node *child;
617 int num = 0;
618
619 for_each_child_of_node(np, child)
620 num++;
621
622 return num;
623}
624
625static inline int of_get_available_child_count(const struct device_node *np)
626{
627 struct device_node *child;
628 int num = 0;
629
630 for_each_available_child_of_node(np, child)
631 num++;
632
633 return num;
634}
635
621#if defined(CONFIG_PROC_FS) && defined(CONFIG_PROC_DEVICETREE) 636#if defined(CONFIG_PROC_FS) && defined(CONFIG_PROC_DEVICETREE)
622extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *); 637extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
623extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop); 638extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop);