Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dt: add of_get_child_count helper function

Currently most code to get child count in kernel are almost same,
add a helper to implement this function for dt to use.

Cc: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Dong Aisheng and committed by
Linus Walleij
183f1d0c 4650b7cb

+16
+16
include/linux/of.h
··· 193 193 for (child = of_get_next_child(parent, NULL); child != NULL; \ 194 194 child = of_get_next_child(parent, child)) 195 195 196 + static inline int of_get_child_count(const struct device_node *np) 197 + { 198 + struct device_node *child; 199 + int num = 0; 200 + 201 + for_each_child_of_node(np, child) 202 + num++; 203 + 204 + return num; 205 + } 206 + 196 207 extern struct device_node *of_find_node_with_property( 197 208 struct device_node *from, const char *prop_name); 198 209 #define for_each_node_with_property(dn, prop_name) \ ··· 310 299 311 300 #define for_each_child_of_node(parent, child) \ 312 301 while (0) 302 + 303 + static inline int of_get_child_count(const struct device_node *np) 304 + { 305 + return 0; 306 + } 313 307 314 308 static inline int of_device_is_compatible(const struct device_node *device, 315 309 const char *name)