diff options
Diffstat (limited to 'include')
| -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 70c64ba17fa5..b59f2e41c7ce 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
| @@ -250,6 +250,8 @@ extern struct device_node *of_find_node_with_property( | |||
| 250 | extern struct property *of_find_property(const struct device_node *np, | 250 | extern struct property *of_find_property(const struct device_node *np, |
| 251 | const char *name, | 251 | const char *name, |
| 252 | int *lenp); | 252 | int *lenp); |
| 253 | extern int of_property_count_elems_of_size(const struct device_node *np, | ||
| 254 | const char *propname, int elem_size); | ||
| 253 | extern int of_property_read_u32_index(const struct device_node *np, | 255 | extern int of_property_read_u32_index(const struct device_node *np, |
| 254 | const char *propname, | 256 | const char *propname, |
| 255 | u32 index, u32 *out_value); | 257 | u32 index, u32 *out_value); |
| @@ -431,6 +433,12 @@ static inline struct device_node *of_find_compatible_node( | |||
| 431 | return NULL; | 433 | return NULL; |
| 432 | } | 434 | } |
| 433 | 435 | ||
| 436 | static inline int of_property_count_elems_of_size(const struct device_node *np, | ||
| 437 | const char *propname, int elem_size) | ||
| 438 | { | ||
| 439 | return -ENOSYS; | ||
| 440 | } | ||
| 441 | |||
| 434 | static inline int of_property_read_u32_index(const struct device_node *np, | 442 | static inline int of_property_read_u32_index(const struct device_node *np, |
| 435 | const char *propname, u32 index, u32 *out_value) | 443 | const char *propname, u32 index, u32 *out_value) |
| 436 | { | 444 | { |
| @@ -570,6 +578,74 @@ static inline int of_node_to_nid(struct device_node *device) { return 0; } | |||
| 570 | #endif | 578 | #endif |
| 571 | 579 | ||
| 572 | /** | 580 | /** |
| 581 | * of_property_count_u8_elems - Count the number of u8 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 u8 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 u8 and -ENODATA if the | ||
| 589 | * property does not have a value. | ||
| 590 | */ | ||
| 591 | static inline int of_property_count_u8_elems(const struct device_node *np, | ||
| 592 | const char *propname) | ||
| 593 | { | ||
| 594 | return of_property_count_elems_of_size(np, propname, sizeof(u8)); | ||
| 595 | } | ||
| 596 | |||
| 597 | /** | ||
| 598 | * of_property_count_u16_elems - Count the number of u16 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 u16 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 u16 and -ENODATA if the | ||
| 606 | * property does not have a value. | ||
| 607 | */ | ||
| 608 | static inline int of_property_count_u16_elems(const struct device_node *np, | ||
| 609 | const char *propname) | ||
| 610 | { | ||
| 611 | return of_property_count_elems_of_size(np, propname, sizeof(u16)); | ||
| 612 | } | ||
| 613 | |||
| 614 | /** | ||
| 615 | * of_property_count_u32_elems - Count the number of u32 elements in a property | ||
| 616 | * | ||
| 617 | * @np: device node from which the property value is to be read. | ||
| 618 | * @propname: name of the property to be searched. | ||
| 619 | * | ||
| 620 | * Search for a property in a device node and count the number of u32 elements | ||
| 621 | * in it. Returns number of elements on sucess, -EINVAL if the property does | ||
| 622 | * not exist or its length does not match a multiple of u32 and -ENODATA if the | ||
| 623 | * property does not have a value. | ||
| 624 | */ | ||
| 625 | static inline int of_property_count_u32_elems(const struct device_node *np, | ||
| 626 | const char *propname) | ||
| 627 | { | ||
| 628 | return of_property_count_elems_of_size(np, propname, sizeof(u32)); | ||
| 629 | } | ||
| 630 | |||
| 631 | /** | ||
| 632 | * of_property_count_u64_elems - Count the number of u64 elements in a property | ||
| 633 | * | ||
| 634 | * @np: device node from which the property value is to be read. | ||
| 635 | * @propname: name of the property to be searched. | ||
| 636 | * | ||
| 637 | * Search for a property in a device node and count the number of u64 elements | ||
| 638 | * in it. Returns number of elements on sucess, -EINVAL if the property does | ||
| 639 | * not exist or its length does not match a multiple of u64 and -ENODATA if the | ||
| 640 | * property does not have a value. | ||
| 641 | */ | ||
| 642 | static inline int of_property_count_u64_elems(const struct device_node *np, | ||
| 643 | const char *propname) | ||
| 644 | { | ||
| 645 | return of_property_count_elems_of_size(np, propname, sizeof(u64)); | ||
| 646 | } | ||
| 647 | |||
| 648 | /** | ||
| 573 | * of_property_read_bool - Findfrom a property | 649 | * of_property_read_bool - Findfrom a property |
| 574 | * @np: device node from which the property value is to be read. | 650 | * @np: device node from which the property value is to be read. |
| 575 | * @propname: name of the property to be searched. | 651 | * @propname: name of the property to be searched. |
