aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@linaro.org>2014-03-04 03:44:10 -0500
committerGrant Likely <grant.likely@linaro.org>2014-03-04 03:44:10 -0500
commitdab2310d9d90eded48625c5382c6a60389bf8ca9 (patch)
tree9327cc815d69dec23aebf03407e3fa82b6d2fbaa /include/linux/of.h
parenta3dbeb5b45af5b6113385db89fce2a8279278e8b (diff)
parent0414855fdc4a40da05221fc6062cccbc0c30f169 (diff)
Merge tag 'v3.14-rc5' into HEAD
Linux 3.14-rc5
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 0ea516ed22c0..b3d0f6d86e3b 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -189,35 +189,15 @@ static inline const char *of_node_full_name(const struct device_node *np)
189 189
190extern struct device_node *of_find_node_by_name(struct device_node *from, 190extern struct device_node *of_find_node_by_name(struct device_node *from,
191 const char *name); 191 const char *name);
192#define for_each_node_by_name(dn, name) \
193 for (dn = of_find_node_by_name(NULL, name); dn; \
194 dn = of_find_node_by_name(dn, name))
195extern struct device_node *of_find_node_by_type(struct device_node *from, 192extern struct device_node *of_find_node_by_type(struct device_node *from,
196 const char *type); 193 const char *type);
197#define for_each_node_by_type(dn, type) \
198 for (dn = of_find_node_by_type(NULL, type); dn; \
199 dn = of_find_node_by_type(dn, type))
200extern struct device_node *of_find_compatible_node(struct device_node *from, 194extern struct device_node *of_find_compatible_node(struct device_node *from,
201 const char *type, const char *compat); 195 const char *type, const char *compat);
202#define for_each_compatible_node(dn, type, compatible) \
203 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
204 dn = of_find_compatible_node(dn, type, compatible))
205extern struct device_node *of_find_matching_node_and_match( 196extern struct device_node *of_find_matching_node_and_match(
206 struct device_node *from, 197 struct device_node *from,
207 const struct of_device_id *matches, 198 const struct of_device_id *matches,
208 const struct of_device_id **match); 199 const struct of_device_id **match);
209static inline struct device_node *of_find_matching_node( 200
210 struct device_node *from,
211 const struct of_device_id *matches)
212{
213 return of_find_matching_node_and_match(from, matches, NULL);
214}
215#define for_each_matching_node(dn, matches) \
216 for (dn = of_find_matching_node(NULL, matches); dn; \
217 dn = of_find_matching_node(dn, matches))
218#define for_each_matching_node_and_match(dn, matches, match) \
219 for (dn = of_find_matching_node_and_match(NULL, matches, match); \
220 dn; dn = of_find_matching_node_and_match(dn, matches, match))
221extern struct device_node *of_find_node_by_path(const char *path); 201extern struct device_node *of_find_node_by_path(const char *path);
222extern struct device_node *of_find_node_by_phandle(phandle handle); 202extern struct device_node *of_find_node_by_phandle(phandle handle);
223extern struct device_node *of_get_parent(const struct device_node *node); 203extern struct device_node *of_get_parent(const struct device_node *node);
@@ -229,43 +209,11 @@ extern struct device_node *of_get_next_available_child(
229 209
230extern struct device_node *of_get_child_by_name(const struct device_node *node, 210extern struct device_node *of_get_child_by_name(const struct device_node *node,
231 const char *name); 211 const char *name);
232#define for_each_child_of_node(parent, child) \
233 for (child = of_get_next_child(parent, NULL); child != NULL; \
234 child = of_get_next_child(parent, child))
235
236#define for_each_available_child_of_node(parent, child) \
237 for (child = of_get_next_available_child(parent, NULL); child != NULL; \
238 child = of_get_next_available_child(parent, child))
239
240static inline int of_get_child_count(const struct device_node *np)
241{
242 struct device_node *child;
243 int num = 0;
244
245 for_each_child_of_node(np, child)
246 num++;
247
248 return num;
249}
250
251static inline int of_get_available_child_count(const struct device_node *np)
252{
253 struct device_node *child;
254 int num = 0;
255
256 for_each_available_child_of_node(np, child)
257 num++;
258
259 return num;
260}
261 212
262/* cache lookup */ 213/* cache lookup */
263extern struct device_node *of_find_next_cache_node(const struct device_node *); 214extern struct device_node *of_find_next_cache_node(const struct device_node *);
264extern struct device_node *of_find_node_with_property( 215extern struct device_node *of_find_node_with_property(
265 struct device_node *from, const char *prop_name); 216 struct device_node *from, const char *prop_name);
266#define for_each_node_with_property(dn, prop_name) \
267 for (dn = of_find_node_with_property(NULL, prop_name); dn; \
268 dn = of_find_node_with_property(dn, prop_name))
269 217
270extern struct property *of_find_property(const struct device_node *np, 218extern struct property *of_find_property(const struct device_node *np,
271 const char *name, 219 const char *name,
@@ -387,42 +335,53 @@ static inline struct device_node *of_find_node_by_name(struct device_node *from,
387 return NULL; 335 return NULL;
388} 336}
389 337
390static inline struct device_node *of_get_parent(const struct device_node *node) 338static inline struct device_node *of_find_node_by_type(struct device_node *from,
339 const char *type)
391{ 340{
392 return NULL; 341 return NULL;
393} 342}
394 343
395static inline bool of_have_populated_dt(void) 344static inline struct device_node *of_find_matching_node_and_match(
345 struct device_node *from,
346 const struct of_device_id *matches,
347 const struct of_device_id **match)
396{ 348{
397 return false; 349 return NULL;
398} 350}
399 351
400/* Kill an unused variable warning on a device_node pointer */ 352static inline struct device_node *of_get_parent(const struct device_node *node)
401static inline void __of_use_dn(const struct device_node *np)
402{ 353{
354 return NULL;
403} 355}
404 356
405#define for_each_child_of_node(parent, child) \ 357static inline struct device_node *of_get_next_child(
406 while (__of_use_dn(parent), __of_use_dn(child), 0) 358 const struct device_node *node, struct device_node *prev)
359{
360 return NULL;
361}
407 362
408#define for_each_available_child_of_node(parent, child) \ 363static inline struct device_node *of_get_next_available_child(
409 while (0) 364 const struct device_node *node, struct device_node *prev)
365{
366 return NULL;
367}
410 368
411static inline struct device_node *of_get_child_by_name( 369static inline struct device_node *of_find_node_with_property(
412 const struct device_node *node, 370 struct device_node *from, const char *prop_name)
413 const char *name)
414{ 371{
415 return NULL; 372 return NULL;
416} 373}
417 374
418static inline int of_get_child_count(const struct device_node *np) 375static inline bool of_have_populated_dt(void)
419{ 376{
420 return 0; 377 return false;
421} 378}
422 379
423static inline int of_get_available_child_count(const struct device_node *np) 380static inline struct device_node *of_get_child_by_name(
381 const struct device_node *node,
382 const char *name)
424{ 383{
425 return 0; 384 return NULL;
426} 385}
427 386
428static inline int of_device_is_compatible(const struct device_node *device, 387static inline int of_device_is_compatible(const struct device_node *device,
@@ -589,6 +548,13 @@ extern int of_node_to_nid(struct device_node *np);
589static inline int of_node_to_nid(struct device_node *device) { return 0; } 548static inline int of_node_to_nid(struct device_node *device) { return 0; }
590#endif 549#endif
591 550
551static inline struct device_node *of_find_matching_node(
552 struct device_node *from,
553 const struct of_device_id *matches)
554{
555 return of_find_matching_node_and_match(from, matches, NULL);
556}
557
592/** 558/**
593 * of_property_read_bool - Findfrom a property 559 * of_property_read_bool - Findfrom a property
594 * @np: device node from which the property value is to be read. 560 * @np: device node from which the property value is to be read.
@@ -638,6 +604,55 @@ static inline int of_property_read_u32(const struct device_node *np,
638 s; \ 604 s; \
639 s = of_prop_next_string(prop, s)) 605 s = of_prop_next_string(prop, s))
640 606
607#define for_each_node_by_name(dn, name) \
608 for (dn = of_find_node_by_name(NULL, name); dn; \
609 dn = of_find_node_by_name(dn, name))
610#define for_each_node_by_type(dn, type) \
611 for (dn = of_find_node_by_type(NULL, type); dn; \
612 dn = of_find_node_by_type(dn, type))
613#define for_each_compatible_node(dn, type, compatible) \
614 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
615 dn = of_find_compatible_node(dn, type, compatible))
616#define for_each_matching_node(dn, matches) \
617 for (dn = of_find_matching_node(NULL, matches); dn; \
618 dn = of_find_matching_node(dn, matches))
619#define for_each_matching_node_and_match(dn, matches, match) \
620 for (dn = of_find_matching_node_and_match(NULL, matches, match); \
621 dn; dn = of_find_matching_node_and_match(dn, matches, match))
622
623#define for_each_child_of_node(parent, child) \
624 for (child = of_get_next_child(parent, NULL); child != NULL; \
625 child = of_get_next_child(parent, child))
626#define for_each_available_child_of_node(parent, child) \
627 for (child = of_get_next_available_child(parent, NULL); child != NULL; \
628 child = of_get_next_available_child(parent, child))
629
630#define for_each_node_with_property(dn, prop_name) \
631 for (dn = of_find_node_with_property(NULL, prop_name); dn; \
632 dn = of_find_node_with_property(dn, prop_name))
633
634static inline int of_get_child_count(const struct device_node *np)
635{
636 struct device_node *child;
637 int num = 0;
638
639 for_each_child_of_node(np, child)
640 num++;
641
642 return num;
643}
644
645static inline int of_get_available_child_count(const struct device_node *np)
646{
647 struct device_node *child;
648 int num = 0;
649
650 for_each_available_child_of_node(np, child)
651 num++;
652
653 return num;
654}
655
641#if defined(CONFIG_PROC_FS) && defined(CONFIG_PROC_DEVICETREE) 656#if defined(CONFIG_PROC_FS) && defined(CONFIG_PROC_DEVICETREE)
642extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *); 657extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
643extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop); 658extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop);