diff options
Diffstat (limited to 'include/linux/of.h')
-rw-r--r-- | include/linux/of.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index fa7fb1d97458..2ec1083af7ff 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
@@ -193,6 +193,17 @@ extern struct device_node *of_get_next_child(const struct device_node *node, | |||
193 | for (child = of_get_next_child(parent, NULL); child != NULL; \ | 193 | for (child = of_get_next_child(parent, NULL); child != NULL; \ |
194 | child = of_get_next_child(parent, child)) | 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 | extern struct device_node *of_find_node_with_property( | 207 | extern struct device_node *of_find_node_with_property( |
197 | struct device_node *from, const char *prop_name); | 208 | struct device_node *from, const char *prop_name); |
198 | #define for_each_node_with_property(dn, prop_name) \ | 209 | #define for_each_node_with_property(dn, prop_name) \ |
@@ -259,6 +270,37 @@ extern void of_detach_node(struct device_node *); | |||
259 | #endif | 270 | #endif |
260 | 271 | ||
261 | #define of_match_ptr(_ptr) (_ptr) | 272 | #define of_match_ptr(_ptr) (_ptr) |
273 | |||
274 | /* | ||
275 | * struct property *prop; | ||
276 | * const __be32 *p; | ||
277 | * u32 u; | ||
278 | * | ||
279 | * of_property_for_each_u32(np, "propname", prop, p, u) | ||
280 | * printk("U32 value: %x\n", u); | ||
281 | */ | ||
282 | const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, | ||
283 | u32 *pu); | ||
284 | #define of_property_for_each_u32(np, propname, prop, p, u) \ | ||
285 | for (prop = of_find_property(np, propname, NULL), \ | ||
286 | p = of_prop_next_u32(prop, NULL, &u); \ | ||
287 | p; \ | ||
288 | p = of_prop_next_u32(prop, p, &u)) | ||
289 | |||
290 | /* | ||
291 | * struct property *prop; | ||
292 | * const char *s; | ||
293 | * | ||
294 | * of_property_for_each_string(np, "propname", prop, s) | ||
295 | * printk("String value: %s\n", s); | ||
296 | */ | ||
297 | const char *of_prop_next_string(struct property *prop, const char *cur); | ||
298 | #define of_property_for_each_string(np, propname, prop, s) \ | ||
299 | for (prop = of_find_property(np, propname, NULL), \ | ||
300 | s = of_prop_next_string(prop, NULL); \ | ||
301 | s; \ | ||
302 | s = of_prop_next_string(prop, s)) | ||
303 | |||
262 | #else /* CONFIG_OF */ | 304 | #else /* CONFIG_OF */ |
263 | 305 | ||
264 | static inline bool of_have_populated_dt(void) | 306 | static inline bool of_have_populated_dt(void) |
@@ -269,6 +311,11 @@ static inline bool of_have_populated_dt(void) | |||
269 | #define for_each_child_of_node(parent, child) \ | 311 | #define for_each_child_of_node(parent, child) \ |
270 | while (0) | 312 | while (0) |
271 | 313 | ||
314 | static inline int of_get_child_count(const struct device_node *np) | ||
315 | { | ||
316 | return 0; | ||
317 | } | ||
318 | |||
272 | static inline int of_device_is_compatible(const struct device_node *device, | 319 | static inline int of_device_is_compatible(const struct device_node *device, |
273 | const char *name) | 320 | const char *name) |
274 | { | 321 | { |
@@ -349,6 +396,10 @@ static inline int of_machine_is_compatible(const char *compat) | |||
349 | 396 | ||
350 | #define of_match_ptr(_ptr) NULL | 397 | #define of_match_ptr(_ptr) NULL |
351 | #define of_match_node(_matches, _node) NULL | 398 | #define of_match_node(_matches, _node) NULL |
399 | #define of_property_for_each_u32(np, propname, prop, p, u) \ | ||
400 | while (0) | ||
401 | #define of_property_for_each_string(np, propname, prop, s) \ | ||
402 | while (0) | ||
352 | #endif /* CONFIG_OF */ | 403 | #endif /* CONFIG_OF */ |
353 | 404 | ||
354 | /** | 405 | /** |