diff options
author | Jamie Iles <jamie@jamieiles.com> | 2011-09-14 15:49:59 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-10-04 18:59:53 -0400 |
commit | 4cd7f7a31178ff8a15ad2bc1258b9b2bf2cf51a4 (patch) | |
tree | 8cd16ff6014483e3249333816e3d6bf4a2a4cae2 /drivers/of | |
parent | 85888069cf5d0f21312e3ee730458a5e3a553509 (diff) |
dt: add helper to read 64-bit integers
Add a helper similar to of_property_read_u32() that handles 64-bit
integers.
v2/v3: constify device node and property name parameters.
Cc: Grant Likely <grant.likely@secretlab.ca>
Reviewed-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 8abde58cbe82..b970562e0111 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -657,6 +657,35 @@ int of_property_read_u32_array(const struct device_node *np, | |||
657 | EXPORT_SYMBOL_GPL(of_property_read_u32_array); | 657 | EXPORT_SYMBOL_GPL(of_property_read_u32_array); |
658 | 658 | ||
659 | /** | 659 | /** |
660 | * of_property_read_u64 - Find and read a 64 bit integer from a property | ||
661 | * @np: device node from which the property value is to be read. | ||
662 | * @propname: name of the property to be searched. | ||
663 | * @out_value: pointer to return value, modified only if return value is 0. | ||
664 | * | ||
665 | * Search for a property in a device node and read a 64-bit value from | ||
666 | * it. Returns 0 on success, -EINVAL if the property does not exist, | ||
667 | * -ENODATA if property does not have a value, and -EOVERFLOW if the | ||
668 | * property data isn't large enough. | ||
669 | * | ||
670 | * The out_value is modified only if a valid u64 value can be decoded. | ||
671 | */ | ||
672 | int of_property_read_u64(const struct device_node *np, const char *propname, | ||
673 | u64 *out_value) | ||
674 | { | ||
675 | struct property *prop = of_find_property(np, propname, NULL); | ||
676 | |||
677 | if (!prop) | ||
678 | return -EINVAL; | ||
679 | if (!prop->value) | ||
680 | return -ENODATA; | ||
681 | if (sizeof(*out_value) > prop->length) | ||
682 | return -EOVERFLOW; | ||
683 | *out_value = of_read_number(prop->value, 2); | ||
684 | return 0; | ||
685 | } | ||
686 | EXPORT_SYMBOL_GPL(of_property_read_u64); | ||
687 | |||
688 | /** | ||
660 | * of_property_read_string - Find and read a string from a property | 689 | * of_property_read_string - Find and read a string from a property |
661 | * @np: device node from which the property value is to be read. | 690 | * @np: device node from which the property value is to be read. |
662 | * @propname: name of the property to be searched. | 691 | * @propname: name of the property to be searched. |