mirror of
https://github.com/dgibson/dtc.git
synced 2025-12-06 21:25:05 -05:00
libfdt: Add fdt_get_name() to retrieve a node's name
This patch adds a new fdt_get_name() function to libfdt which will return a node's name string (including unit address, if any). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
bd2ae2f41c
commit
9d26eabdc6
5 changed files with 112 additions and 1 deletions
|
|
@ -169,6 +169,30 @@ int fdt_path_offset(const void *fdt, const char *path)
|
|||
return offset;
|
||||
}
|
||||
|
||||
const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
|
||||
{
|
||||
const struct fdt_node_header *nh;
|
||||
int err;
|
||||
|
||||
if ((err = _fdt_check_header(fdt)) != 0)
|
||||
goto fail;
|
||||
|
||||
err = -FDT_ERR_BADOFFSET;
|
||||
nh = fdt_offset_ptr(fdt, nodeoffset, sizeof(*nh));
|
||||
if (!nh || (fdt32_to_cpu(nh->tag) != FDT_BEGIN_NODE))
|
||||
goto fail;
|
||||
|
||||
if (len)
|
||||
*len = strlen(nh->name);
|
||||
|
||||
return nh->name;
|
||||
|
||||
fail:
|
||||
if (len)
|
||||
*len = err;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const struct fdt_property *fdt_get_property(const void *fdt,
|
||||
int nodeoffset,
|
||||
const char *name, int *lenp)
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
|
|||
|
||||
int fdt_path_offset(const void *fdt, const char *path);
|
||||
|
||||
const char *fdt_get_name(const void *fdt, int nodeoffset, int *baselen);
|
||||
|
||||
const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset,
|
||||
const char *name, int *lenp);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue