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>
This commit is contained in:
committed by
Albert ARIBAUD
parent
649d0ffbc1
commit
bed4d89277
24
lib/fdtdec.c
24
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user