diff options
author | Simon Glass <sjg@chromium.org> | 2014-11-10 18:00:19 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2014-11-21 07:24:11 +0100 |
commit | a9f04d49e519383f98689d603facdee227a2f94d (patch) | |
tree | 1b218e35a8b8c0789a119edcdb06c87ba78e62e5 /lib | |
parent | 768e0f52f2d1a9d19842c8d1ded22a96b080a266 (diff) | |
download | u-boot-imx-a9f04d49e519383f98689d603facdee227a2f94d.zip u-boot-imx-a9f04d49e519383f98689d603facdee227a2f94d.tar.gz u-boot-imx-a9f04d49e519383f98689d603facdee227a2f94d.tar.bz2 |
fdt: Add a function to decode a variable-sized u32 array
Sometimes an array can be of variable size up to a maximum. Add a helper
function to decode this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fdtdec.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 9714620..4aa227a 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -485,6 +485,26 @@ int fdtdec_get_int_array(const void *blob, int node, const char *prop_name, return err; } +int fdtdec_get_int_array_count(const void *blob, int node, + const char *prop_name, u32 *array, int count) +{ + const u32 *cell; + int len, elems; + int i; + + debug("%s: %s\n", __func__, prop_name); + cell = fdt_getprop(blob, node, prop_name, &len); + if (!cell) + return -FDT_ERR_NOTFOUND; + elems = len / sizeof(u32); + if (count > elems) + count = elems; + for (i = 0; i < count; i++) + array[i] = fdt32_to_cpu(cell[i]); + + return count; +} + const u32 *fdtdec_locate_array(const void *blob, int node, const char *prop_name, int count) { |