summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnton Staff <robotboy@chromium.org>2012-04-17 09:01:28 +0000
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2012-05-15 08:31:39 +0200
commitbed4d89277629904bfcefa37589c71e4b7424bea (patch)
treefb96d19d9a5484a4a3098c8e12095bfd77a6ac74 /lib
parent649d0ffbc1eca693726937ff40e7d7ab852f4ae9 (diff)
downloadu-boot-imx-bed4d89277629904bfcefa37589c71e4b7424bea.zip
u-boot-imx-bed4d89277629904bfcefa37589c71e4b7424bea.tar.gz
u-boot-imx-bed4d89277629904bfcefa37589c71e4b7424bea.tar.bz2
fdt: Add fdtdec functions to read byte array
Sometimes we don't need a full cell for each value. This provides a simple function to read a byte array, both with and without copying it. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/fdtdec.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 42c3e89..ba5c591 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -476,3 +476,27 @@ int fdtdec_setup_gpio(struct fdt_gpio_state *gpio)
return -1;
return 0;
}
+
+int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
+ u8 *array, int count)
+{
+ const u8 *cell;
+ int err;
+
+ cell = get_prop_check_min_len(blob, node, prop_name, count, &err);
+ if (!err)
+ memcpy(array, cell, count);
+ return err;
+}
+
+const u8 *fdtdec_locate_byte_array(const void *blob, int node,
+ const char *prop_name, int count)
+{
+ const u8 *cell;
+ int err;
+
+ cell = get_prop_check_min_len(blob, node, prop_name, count, &err);
+ if (err)
+ return NULL;
+ return cell;
+}