diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2008-01-11 14:55:05 +1100 |
---|---|---|
committer | Gerald Van Baren <vanbaren@cideas.com> | 2008-03-18 21:03:45 -0400 |
commit | 9eaeb07a7185d852c7aa10735ecd4e9edf24fb5d (patch) | |
tree | c805461c3e8e3e13372e918f0dd0ced4fa4571ea /libfdt | |
parent | fdeb932b1c8a3b615463995c3452d30ee0b12a33 (diff) | |
download | u-boot-imx-9eaeb07a7185d852c7aa10735ecd4e9edf24fb5d.zip u-boot-imx-9eaeb07a7185d852c7aa10735ecd4e9edf24fb5d.tar.gz u-boot-imx-9eaeb07a7185d852c7aa10735ecd4e9edf24fb5d.tar.bz2 |
libfdt: Add fdt_set_name() function
This patch adds an fdt_set_name() function to libfdt, mirroring
fdt_get_name(). This is a r/w function which alters the name of a
given device tree node.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'libfdt')
-rw-r--r-- | libfdt/fdt_rw.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c index 6673f8e..a1c70ff 100644 --- a/libfdt/fdt_rw.c +++ b/libfdt/fdt_rw.c @@ -252,6 +252,30 @@ static int _add_property(void *fdt, int nodeoffset, const char *name, int len, return 0; } +int fdt_set_name(void *fdt, int nodeoffset, const char *name) +{ + char *namep; + int oldlen, newlen; + int err; + + if ((err = rw_check_header(fdt))) + return err; + + namep = (char *)fdt_get_name(fdt, nodeoffset, &oldlen); + if (!namep) + return oldlen; + + newlen = strlen(name); + + err = _blob_splice_struct(fdt, namep, ALIGN(oldlen+1, FDT_TAGSIZE), + ALIGN(newlen+1, FDT_TAGSIZE)); + if (err) + return err; + + memcpy(namep, name, newlen+1); + return 0; +} + int fdt_setprop(void *fdt, int nodeoffset, const char *name, const void *val, int len) { |