mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 13:11:31 +00:00
fdt: Add a function to look up a /chosen property
It is sometimes useful to find a property in the chosen node. Add a function for this. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
This commit is contained in:
parent
44303dfa79
commit
3bc37a50e0
2 changed files with 21 additions and 7 deletions
|
@ -628,7 +628,16 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int node,
|
|||
int *seqp);
|
||||
|
||||
/**
|
||||
* Get the offset of the given chosen node
|
||||
* Get a property from the /chosen node
|
||||
*
|
||||
* @param blob Device tree blob (if NULL, then NULL is returned)
|
||||
* @param name Property name to look up
|
||||
* @return Value of property, or NULL if it does not exist
|
||||
*/
|
||||
const char *fdtdec_get_chosen_prop(const void *blob, const char *name);
|
||||
|
||||
/**
|
||||
* Get the offset of the given /chosen node
|
||||
*
|
||||
* This looks up a property in /chosen containing the path to another node,
|
||||
* then finds the offset of that node.
|
||||
|
|
17
lib/fdtdec.c
17
lib/fdtdec.c
|
@ -601,16 +601,21 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset,
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
const char *fdtdec_get_chosen_prop(const void *blob, const char *name)
|
||||
{
|
||||
int chosen_node;
|
||||
|
||||
if (!blob)
|
||||
return NULL;
|
||||
chosen_node = fdt_path_offset(blob, "/chosen");
|
||||
return fdt_getprop(blob, chosen_node, name, NULL);
|
||||
}
|
||||
|
||||
int fdtdec_get_chosen_node(const void *blob, const char *name)
|
||||
{
|
||||
const char *prop;
|
||||
int chosen_node;
|
||||
int len;
|
||||
|
||||
if (!blob)
|
||||
return -FDT_ERR_NOTFOUND;
|
||||
chosen_node = fdt_path_offset(blob, "/chosen");
|
||||
prop = fdt_getprop(blob, chosen_node, name, &len);
|
||||
prop = fdtdec_get_chosen_prop(blob, name);
|
||||
if (!prop)
|
||||
return -FDT_ERR_NOTFOUND;
|
||||
return fdt_path_offset(blob, prop);
|
||||
|
|
Loading…
Add table
Reference in a new issue