diff options
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r-- | drivers/of/base.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 3823edf2d012..4c2ccde42427 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -1250,6 +1250,39 @@ int of_property_read_u64(const struct device_node *np, const char *propname, | |||
1250 | EXPORT_SYMBOL_GPL(of_property_read_u64); | 1250 | EXPORT_SYMBOL_GPL(of_property_read_u64); |
1251 | 1251 | ||
1252 | /** | 1252 | /** |
1253 | * of_property_read_u64_array - Find and read an array of 64 bit integers | ||
1254 | * from a property. | ||
1255 | * | ||
1256 | * @np: device node from which the property value is to be read. | ||
1257 | * @propname: name of the property to be searched. | ||
1258 | * @out_values: pointer to return value, modified only if return value is 0. | ||
1259 | * @sz: number of array elements to read | ||
1260 | * | ||
1261 | * Search for a property in a device node and read 64-bit value(s) from | ||
1262 | * it. Returns 0 on success, -EINVAL if the property does not exist, | ||
1263 | * -ENODATA if property does not have a value, and -EOVERFLOW if the | ||
1264 | * property data isn't large enough. | ||
1265 | * | ||
1266 | * The out_values is modified only if a valid u64 value can be decoded. | ||
1267 | */ | ||
1268 | int of_property_read_u64_array(const struct device_node *np, | ||
1269 | const char *propname, u64 *out_values, | ||
1270 | size_t sz) | ||
1271 | { | ||
1272 | const __be32 *val = of_find_property_value_of_size(np, propname, | ||
1273 | (sz * sizeof(*out_values))); | ||
1274 | |||
1275 | if (IS_ERR(val)) | ||
1276 | return PTR_ERR(val); | ||
1277 | |||
1278 | while (sz--) { | ||
1279 | *out_values++ = of_read_number(val, 2); | ||
1280 | val += 2; | ||
1281 | } | ||
1282 | return 0; | ||
1283 | } | ||
1284 | |||
1285 | /** | ||
1253 | * of_property_read_string - Find and read a string from a property | 1286 | * of_property_read_string - Find and read a string from a property |
1254 | * @np: device node from which the property value is to be read. | 1287 | * @np: device node from which the property value is to be read. |
1255 | * @propname: name of the property to be searched. | 1288 | * @propname: name of the property to be searched. |