aboutsummaryrefslogtreecommitdiff
path: root/drivers/core/of_access.c
diff options
context:
space:
mode:
authorDario Binacchi <dariobin@libero.it>2020-03-29 18:04:41 +0200
committerSimon Glass <sjg@chromium.org>2020-04-16 08:07:58 -0600
commit4bb7075c830c6f4e4512fe0277ff1f08c5a9e084 (patch)
treea1d8d9d36db2c061edd17dadddfed57a4188470e /drivers/core/of_access.c
parent70573c6c46be96d2e60497d8484b9afb119da8c1 (diff)
downloadu-boot-4bb7075c830c6f4e4512fe0277ff1f08c5a9e084.zip
u-boot-4bb7075c830c6f4e4512fe0277ff1f08c5a9e084.tar.gz
u-boot-4bb7075c830c6f4e4512fe0277ff1f08c5a9e084.tar.bz2
dm: core: support reading a single indexed u32 value
The patch adds helper functions to allow reading a single indexed u32 value from a device-tree property containing multiple u32 values, that is an array of integers. Signed-off-by: Dario Binacchi <dariobin@libero.it> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/of_access.c')
-rw-r--r--drivers/core/of_access.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
index 29e705e..8b2ce7a 100644
--- a/drivers/core/of_access.c
+++ b/drivers/core/of_access.c
@@ -485,6 +485,28 @@ int of_read_u32_array(const struct device_node *np, const char *propname,
return 0;
}
+int of_read_u32_index(const struct device_node *np, const char *propname,
+ int index, u32 *outp)
+{
+ const __be32 *val;
+
+ debug("%s: %s: ", __func__, propname);
+ if (!np)
+ return -EINVAL;
+
+ val = of_find_property_value_of_size(np, propname,
+ sizeof(*outp) * (index + 1));
+ if (IS_ERR(val)) {
+ debug("(not found)\n");
+ return PTR_ERR(val);
+ }
+
+ *outp = be32_to_cpup(val + index);
+ debug("%#x (%d)\n", *outp, *outp);
+
+ return 0;
+}
+
int of_read_u64(const struct device_node *np, const char *propname, u64 *outp)
{
const __be64 *val;