diff options
author | Rob Herring <robh@kernel.org> | 2018-08-22 16:04:40 -0400 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2018-09-28 15:25:58 -0400 |
commit | f1f207e43b8a49ac2ee3c36a64de1f84651c6079 (patch) | |
tree | 0989fbb86c45ef7635bd7a1964e2fc615a5209fc /include/linux/of.h | |
parent | f6707fd6241e483f6fea2caae82d876e422bb11a (diff) |
of: Add cpu node iterator for_each_of_cpu_node()
Iterating thru cpu nodes is a common pattern. Create a common iterator
which can find child nodes either by node name or device_type == cpu.
Using the former will allow for eventually dropping device_type
properties which are deprecated for FDT.
Cc: Frank Rowand <frowand.list@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'include/linux/of.h')
-rw-r--r-- | include/linux/of.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index 99b0ebf49632..1aca0dbd35df 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
@@ -353,6 +353,8 @@ extern const void *of_get_property(const struct device_node *node, | |||
353 | const char *name, | 353 | const char *name, |
354 | int *lenp); | 354 | int *lenp); |
355 | extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); | 355 | extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); |
356 | extern struct device_node *of_get_next_cpu_node(struct device_node *prev); | ||
357 | |||
356 | #define for_each_property_of_node(dn, pp) \ | 358 | #define for_each_property_of_node(dn, pp) \ |
357 | for (pp = dn->properties; pp != NULL; pp = pp->next) | 359 | for (pp = dn->properties; pp != NULL; pp = pp->next) |
358 | 360 | ||
@@ -754,6 +756,11 @@ static inline struct device_node *of_get_cpu_node(int cpu, | |||
754 | return NULL; | 756 | return NULL; |
755 | } | 757 | } |
756 | 758 | ||
759 | static inline struct device_node *of_get_next_cpu_node(struct device_node *prev) | ||
760 | { | ||
761 | return NULL; | ||
762 | } | ||
763 | |||
757 | static inline int of_n_addr_cells(struct device_node *np) | 764 | static inline int of_n_addr_cells(struct device_node *np) |
758 | { | 765 | { |
759 | return 0; | 766 | return 0; |
@@ -1217,6 +1224,10 @@ static inline int of_property_read_s32(const struct device_node *np, | |||
1217 | for (child = of_get_next_available_child(parent, NULL); child != NULL; \ | 1224 | for (child = of_get_next_available_child(parent, NULL); child != NULL; \ |
1218 | child = of_get_next_available_child(parent, child)) | 1225 | child = of_get_next_available_child(parent, child)) |
1219 | 1226 | ||
1227 | #define for_each_of_cpu_node(cpu) \ | ||
1228 | for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \ | ||
1229 | cpu = of_get_next_cpu_node(cpu)) | ||
1230 | |||
1220 | #define for_each_node_with_property(dn, prop_name) \ | 1231 | #define for_each_node_with_property(dn, prop_name) \ |
1221 | for (dn = of_find_node_with_property(NULL, prop_name); dn; \ | 1232 | for (dn = of_find_node_with_property(NULL, prop_name); dn; \ |
1222 | dn = of_find_node_with_property(dn, prop_name)) | 1233 | dn = of_find_node_with_property(dn, prop_name)) |