From 80ad781643b68c91316687051965e12021abeab6 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Fri, 22 Jul 2011 13:55:37 +0200 Subject: device tree: add add_subnode command We want to be able to create subnodes in our device tree, so export it through the qemu device tree abstraction framework. Signed-off-by: Alexander Graf --- device_tree.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'device_tree.c') diff --git a/device_tree.c b/device_tree.c index 23e89e3..f4a78c8 100644 --- a/device_tree.c +++ b/device_tree.c @@ -118,3 +118,27 @@ int qemu_devtree_nop_node(void *fdt, const char *node_path) return fdt_nop_node(fdt, offset); } + +int qemu_devtree_add_subnode(void *fdt, const char *name) +{ + int offset; + char *dupname = g_strdup(name); + char *basename = strrchr(dupname, '/'); + int retval; + + if (!basename) { + return -1; + } + + basename[0] = '\0'; + basename++; + + offset = fdt_path_offset(fdt, dupname); + if (offset < 0) { + return offset; + } + + retval = fdt_add_subnode(fdt, offset, basename); + g_free(dupname); + return retval; +} -- cgit v1.1