Skip to content

Commit

Permalink
device tree: add add_subnode command
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
agraf committed Oct 6, 2011
1 parent 10f25a4 commit 80ad781
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions device_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions device_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
int qemu_devtree_setprop_string(void *fdt, const char *node_path,
const char *property, const char *string);
int qemu_devtree_nop_node(void *fdt, const char *node_path);
int qemu_devtree_add_subnode(void *fdt, const char *name);

#endif /* __DEVICE_TREE_H__ */

0 comments on commit 80ad781

Please sign in to comment.