diff options
Diffstat (limited to 'include/linux/of.h')
-rw-r--r-- | include/linux/of.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index 435cb995904d..83d1ac80c91e 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
@@ -198,6 +198,8 @@ extern struct device_node *of_find_node_with_property( | |||
198 | extern struct property *of_find_property(const struct device_node *np, | 198 | extern struct property *of_find_property(const struct device_node *np, |
199 | const char *name, | 199 | const char *name, |
200 | int *lenp); | 200 | int *lenp); |
201 | extern int of_property_count_elems_of_size(const struct device_node *np, | ||
202 | const char *propname, int elem_size); | ||
201 | extern int of_property_read_u32_index(const struct device_node *np, | 203 | extern int of_property_read_u32_index(const struct device_node *np, |
202 | const char *propname, | 204 | const char *propname, |
203 | u32 index, u32 *out_value); | 205 | u32 index, u32 *out_value); |
@@ -390,6 +392,12 @@ static inline struct device_node *of_find_compatible_node( | |||
390 | return NULL; | 392 | return NULL; |
391 | } | 393 | } |
392 | 394 | ||
395 | static inline int of_property_count_elems_of_size(const struct device_node *np, | ||
396 | const char *propname, int elem_size) | ||
397 | { | ||
398 | return -ENOSYS; | ||
399 | } | ||
400 | |||
393 | static inline int of_property_read_u32_index(const struct device_node *np, | 401 | static inline int of_property_read_u32_index(const struct device_node *np, |
394 | const char *propname, u32 index, u32 *out_value) | 402 | const char *propname, u32 index, u32 *out_value) |
395 | { | 403 | { |
@@ -536,6 +544,74 @@ static inline struct device_node *of_find_matching_node( | |||
536 | } | 544 | } |
537 | 545 | ||
538 | /** | 546 | /** |
547 | * of_property_count_u8_elems - Count the number of u8 elements in a property | ||
548 | * | ||
549 | * @np: device node from which the property value is to be read. | ||
550 | * @propname: name of the property to be searched. | ||
551 | * | ||
552 | * Search for a property in a device node and count the number of u8 elements | ||
553 | * in it. Returns number of elements on sucess, -EINVAL if the property does | ||
554 | * not exist or its length does not match a multiple of u8 and -ENODATA if the | ||
555 | * property does not have a value. | ||
556 | */ | ||
557 | static inline int of_property_count_u8_elems(const struct device_node *np, | ||
558 | const char *propname) | ||
559 | { | ||
560 | return of_property_count_elems_of_size(np, propname, sizeof(u8)); | ||
561 | } | ||
562 | |||
563 | /** | ||
564 | * of_property_count_u16_elems - Count the number of u16 elements in a property | ||
565 | * | ||
566 | * @np: device node from which the property value is to be read. | ||
567 | * @propname: name of the property to be searched. | ||
568 | * | ||
569 | * Search for a property in a device node and count the number of u16 elements | ||
570 | * in it. Returns number of elements on sucess, -EINVAL if the property does | ||
571 | * not exist or its length does not match a multiple of u16 and -ENODATA if the | ||
572 | * property does not have a value. | ||
573 | */ | ||
574 | static inline int of_property_count_u16_elems(const struct device_node *np, | ||
575 | const char *propname) | ||
576 | { | ||
577 | return of_property_count_elems_of_size(np, propname, sizeof(u16)); | ||
578 | } | ||
579 | |||
580 | /** | ||
581 | * of_property_count_u32_elems - Count the number of u32 elements in a property | ||
582 | * | ||
583 | * @np: device node from which the property value is to be read. | ||
584 | * @propname: name of the property to be searched. | ||
585 | * | ||
586 | * Search for a property in a device node and count the number of u32 elements | ||
587 | * in it. Returns number of elements on sucess, -EINVAL if the property does | ||
588 | * not exist or its length does not match a multiple of u32 and -ENODATA if the | ||
589 | * property does not have a value. | ||
590 | */ | ||
591 | static inline int of_property_count_u32_elems(const struct device_node *np, | ||
592 | const char *propname) | ||
593 | { | ||
594 | return of_property_count_elems_of_size(np, propname, sizeof(u32)); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * of_property_count_u64_elems - Count the number of u64 elements in a property | ||
599 | * | ||
600 | * @np: device node from which the property value is to be read. | ||
601 | * @propname: name of the property to be searched. | ||
602 | * | ||
603 | * Search for a property in a device node and count the number of u64 elements | ||
604 | * in it. Returns number of elements on sucess, -EINVAL if the property does | ||
605 | * not exist or its length does not match a multiple of u64 and -ENODATA if the | ||
606 | * property does not have a value. | ||
607 | */ | ||
608 | static inline int of_property_count_u64_elems(const struct device_node *np, | ||
609 | const char *propname) | ||
610 | { | ||
611 | return of_property_count_elems_of_size(np, propname, sizeof(u64)); | ||
612 | } | ||
613 | |||
614 | /** | ||
539 | * of_property_read_bool - Findfrom a property | 615 | * of_property_read_bool - Findfrom a property |
540 | * @np: device node from which the property value is to be read. | 616 | * @np: device node from which the property value is to be read. |
541 | * @propname: name of the property to be searched. | 617 | * @propname: name of the property to be searched. |