mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 15:14:43 +00:00
fdt: Add function to locate an array in the device tree
fdtdec_locate_array() locates an integer array but does not copy it. This saves the caller having to allocated wasted space. Access to array elements should be through the fdt32_to_cpu() macro. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
This commit is contained in:
parent
39007ec8cd
commit
96875e7d3b
2 changed files with 30 additions and 0 deletions
|
@ -271,6 +271,25 @@ int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name);
|
|||
int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
|
||||
u32 *array, int count);
|
||||
|
||||
/**
|
||||
* Look up a property in a node and return a pointer to its contents as a
|
||||
* unsigned int array of given length. The property must have at least enough
|
||||
* data for the array ('count' cells). It may have more, but this will be
|
||||
* ignored. The data is not copied.
|
||||
*
|
||||
* Note that you must access elements of the array with fdt32_to_cpu(),
|
||||
* since the elements will be big endian even on a little endian machine.
|
||||
*
|
||||
* @param blob FDT blob
|
||||
* @param node node to examine
|
||||
* @param prop_name name of property to find
|
||||
* @param count number of array elements
|
||||
* @return pointer to array if found, or NULL if the property is not
|
||||
* found or there is not enough data
|
||||
*/
|
||||
const u32 *fdtdec_locate_array(const void *blob, int node,
|
||||
const char *prop_name, int count);
|
||||
|
||||
/**
|
||||
* Look up a boolean property in a node and return it.
|
||||
*
|
||||
|
|
11
lib/fdtdec.c
11
lib/fdtdec.c
|
@ -363,6 +363,17 @@ int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
|
|||
return err;
|
||||
}
|
||||
|
||||
const u32 *fdtdec_locate_array(const void *blob, int node,
|
||||
const char *prop_name, int count)
|
||||
{
|
||||
const u32 *cell;
|
||||
int err;
|
||||
|
||||
cell = get_prop_check_min_len(blob, node, prop_name,
|
||||
sizeof(u32) * count, &err);
|
||||
return err ? NULL : cell;
|
||||
}
|
||||
|
||||
int fdtdec_get_bool(const void *blob, int node, const char *prop_name)
|
||||
{
|
||||
const s32 *cell;
|
||||
|
|
Loading…
Reference in a new issue