aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/of.h')
-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 b59f2e41c7ce..83d1ac80c91e 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,
@@ -369,42 +317,53 @@ static inline struct device_node *of_find_node_by_name(struct device_node *from,
369 return NULL; 317 return NULL;
370} 318}
371 319
372static inline struct device_node *of_get_parent(const struct device_node *node) 320static inline struct device_node *of_find_node_by_type(struct device_node *from,
321 const char *type)
373{ 322{
374 return NULL; 323 return NULL;
375} 324}
376 325
377static inline bool of_have_populated_dt(void) 326static inline struct device_node *of_find_matching_node_and_match(
327 struct device_node *from,
328 const struct of_device_id *matches,
329 const struct of_device_id **match)
378{ 330{
379 return false; 331 return NULL;
380} 332}
381 333
382/* Kill an unused variable warning on a device_node pointer */ 334static inline struct device_node *of_get_parent(const struct device_node *node)
383static inline void __of_use_dn(const struct device_node *np)
384{ 335{
336 return NULL;
385} 337}
386 338
387#define for_each_child_of_node(parent, child) \ 339static inline struct device_node *of_get_next_child(
388 while (__of_use_dn(parent), __of_use_dn(child), 0) 340 const struct device_node *node, struct device_node *prev)
341{
342 return NULL;
343}
389 344
390#define for_each_available_child_of_node(parent, child) \ 345static inline struct device_node *of_get_next_available_child(
391 while (0) 346 const struct device_node *node, struct device_node *prev)
347{
348 return NULL;
349}
392 350
393static inline struct device_node *of_get_child_by_name( 351static inline struct device_node *of_find_node_with_property(
394 const struct device_node *node, 352 struct device_node *from, const char *prop_name)
395 const char *name)
396{ 353{
397 return NULL; 354 return NULL;
398} 355}
399 356
400static inline int of_get_child_count(const struct device_node *np) 357static inline bool of_have_populated_dt(void)
401{ 358{
402 return 0; 359 return false;
403} 360}
404 361
405static inline int of_get_available_child_count(const struct device_node *np) 362static inline struct device_node *of_get_child_by_name(
363 const struct device_node *node,
364 const char *name)
406{ 365{
407 return 0; 366 return NULL;
408} 367}
409 368
410static inline int of_device_is_compatible(const struct device_node *device, 369static inline int of_device_is_compatible(const struct device_node *device,
@@ -577,6 +536,13 @@ extern int of_node_to_nid(struct device_node *np);
577static inline int of_node_to_nid(struct device_node *device) { return 0; } 536static inline int of_node_to_nid(struct device_node *device) { return 0; }
578#endif 537#endif
579 538
539static inline struct device_node *of_find_matching_node(
540 struct device_node *from,
541 const struct of_device_id *matches)
542{
543 return of_find_matching_node_and_match(from, matches, NULL);
544}
545
580/** 546/**
581 * of_property_count_u8_elems - Count the number of u8 elements in a property 547 * of_property_count_u8_elems - Count the number of u8 elements in a property
582 * 548 *
@@ -694,6 +660,55 @@ static inline int of_property_read_u32(const struct device_node *np,
694 s; \ 660 s; \
695 s = of_prop_next_string(prop, s)) 661 s = of_prop_next_string(prop, s))
696 662
663#define for_each_node_by_name(dn, name) \
664 for (dn = of_find_node_by_name(NULL, name); dn; \
665 dn = of_find_node_by_name(dn, name))
666#define for_each_node_by_type(dn, type) \
667 for (dn = of_find_node_by_type(NULL, type); dn; \
668 dn = of_find_node_by_type(dn, type))
669#define for_each_compatible_node(dn, type, compatible) \
670 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
671 dn = of_find_compatible_node(dn, type, compatible))
672#define for_each_matching_node(dn, matches) \
673 for (dn = of_find_matching_node(NULL, matches); dn; \
674 dn = of_find_matching_node(dn, matches))
675#define for_each_matching_node_and_match(dn, matches, match) \
676 for (dn = of_find_matching_node_and_match(NULL, matches, match); \
677 dn; dn = of_find_matching_node_and_match(dn, matches, match))
678
679#define for_each_child_of_node(parent, child) \
680 for (child = of_get_next_child(parent, NULL); child != NULL; \
681 child = of_get_next_child(parent, child))
682#define for_each_available_child_of_node(parent, child) \
683 for (child = of_get_next_available_child(parent, NULL); child != NULL; \
684 child = of_get_next_available_child(parent, child))
685
686#define for_each_node_with_property(dn, prop_name) \
687 for (dn = of_find_node_with_property(NULL, prop_name); dn; \
688 dn = of_find_node_with_property(dn, prop_name))
689
690static inline int of_get_child_count(const struct device_node *np)
691{
692 struct device_node *child;
693 int num = 0;
694
695 for_each_child_of_node(np, child)
696 num++;
697
698 return num;
699}
700
701static inline int of_get_available_child_count(const struct device_node *np)
702{
703 struct device_node *child;
704 int num = 0;
705
706 for_each_available_child_of_node(np, child)
707 num++;
708
709 return num;
710}
711
697#if defined(CONFIG_PROC_FS) && defined(CONFIG_PROC_DEVICETREE) 712#if defined(CONFIG_PROC_FS) && defined(CONFIG_PROC_DEVICETREE)
698extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *); 713extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
699extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop); 714extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop);