diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-08-30 14:54:04 +1000 |
---|---|---|
committer | Jon Loeliger <jdl@freescale.com> | 2007-08-30 08:42:59 -0500 |
commit | 9d26eabdc6ff9d9676436596876c732de741b9af (patch) | |
tree | 5ee82a7785f620acf8b28a39abd2339eb93e8636 /libfdt | |
parent | bd2ae2f41cb1ef7612e3b2cb7179bc6be6ec7f44 (diff) | |
download | dtc-9d26eabdc6ff9d9676436596876c732de741b9af.zip dtc-9d26eabdc6ff9d9676436596876c732de741b9af.tar.gz dtc-9d26eabdc6ff9d9676436596876c732de741b9af.tar.bz2 |
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>
Diffstat (limited to 'libfdt')
-rw-r--r-- | libfdt/fdt_ro.c | 24 | ||||
-rw-r--r-- | libfdt/libfdt.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c index e7a78de..9ff862b 100644 --- a/libfdt/fdt_ro.c +++ b/libfdt/fdt_ro.c @@ -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) diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h index d33a64f..f8fd459 100644 --- a/libfdt/libfdt.h +++ b/libfdt/libfdt.h @@ -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); |