diff options
author | Grant Likely <grant.likely@linaro.org> | 2014-03-04 03:44:10 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2014-03-04 03:44:10 -0500 |
commit | dab2310d9d90eded48625c5382c6a60389bf8ca9 (patch) | |
tree | 9327cc815d69dec23aebf03407e3fa82b6d2fbaa /include/linux/of.h | |
parent | a3dbeb5b45af5b6113385db89fce2a8279278e8b (diff) | |
parent | 0414855fdc4a40da05221fc6062cccbc0c30f169 (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.h | 153 |
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 | ||
190 | extern struct device_node *of_find_node_by_name(struct device_node *from, | 190 | extern 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)) | ||
195 | extern struct device_node *of_find_node_by_type(struct device_node *from, | 192 | extern 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)) | ||
200 | extern struct device_node *of_find_compatible_node(struct device_node *from, | 194 | extern 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)) | ||
205 | extern struct device_node *of_find_matching_node_and_match( | 196 | extern 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); |
209 | static 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)) | ||
221 | extern struct device_node *of_find_node_by_path(const char *path); | 201 | extern struct device_node *of_find_node_by_path(const char *path); |
222 | extern struct device_node *of_find_node_by_phandle(phandle handle); | 202 | extern struct device_node *of_find_node_by_phandle(phandle handle); |
223 | extern struct device_node *of_get_parent(const struct device_node *node); | 203 | extern 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 | ||
230 | extern struct device_node *of_get_child_by_name(const struct device_node *node, | 210 | extern 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 | |||
240 | static 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 | |||
251 | static 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 */ |
263 | extern struct device_node *of_find_next_cache_node(const struct device_node *); | 214 | extern struct device_node *of_find_next_cache_node(const struct device_node *); |
264 | extern struct device_node *of_find_node_with_property( | 215 | extern 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 | ||
270 | extern struct property *of_find_property(const struct device_node *np, | 218 | extern 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 | ||
390 | static inline struct device_node *of_get_parent(const struct device_node *node) | 338 | static 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 | ||
395 | static inline bool of_have_populated_dt(void) | 344 | static 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 */ | 352 | static inline struct device_node *of_get_parent(const struct device_node *node) |
401 | static 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) \ | 357 | static 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) \ | 363 | static 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 | ||
411 | static inline struct device_node *of_get_child_by_name( | 369 | static 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 | ||
418 | static inline int of_get_child_count(const struct device_node *np) | 375 | static inline bool of_have_populated_dt(void) |
419 | { | 376 | { |
420 | return 0; | 377 | return false; |
421 | } | 378 | } |
422 | 379 | ||
423 | static inline int of_get_available_child_count(const struct device_node *np) | 380 | static 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 | ||
428 | static inline int of_device_is_compatible(const struct device_node *device, | 387 | static 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); | |||
589 | static inline int of_node_to_nid(struct device_node *device) { return 0; } | 548 | static inline int of_node_to_nid(struct device_node *device) { return 0; } |
590 | #endif | 549 | #endif |
591 | 550 | ||
551 | static 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 | |||
634 | static 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 | |||
645 | static 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) |
642 | extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *); | 657 | extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *); |
643 | extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop); | 658 | extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop); |