diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-02-20 23:04:24 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-06 11:41:27 +0100 |
commit | dbaf66d8f73c834ae6fca9fb1bf0a296c50d7cb9 (patch) | |
tree | 5eb038e5c2bea1469b1f5ad24409589977a24908 /commands/of_node.c | |
parent | 6be475957926afe3e3af97dcdc9e001f10b0d3d5 (diff) | |
download | barebox-dbaf66d8f73c834ae6fca9fb1bf0a296c50d7cb9.tar.gz barebox-dbaf66d8f73c834ae6fca9fb1bf0a296c50d7cb9.tar.xz |
of_node command: use of_create_node
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/of_node.c')
-rw-r--r-- | commands/of_node.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/commands/of_node.c b/commands/of_node.c index a370e2699a..bf9799caa8 100644 --- a/commands/of_node.c +++ b/commands/of_node.c @@ -39,6 +39,7 @@ static int do_of_node(int argc, char *argv[]) int create = 0; char *path = NULL; struct device_node *node = NULL; + struct device_node *root; while ((opt = getopt(argc, argv, "cd")) > 0) { switch (opt) { @@ -57,27 +58,19 @@ static int do_of_node(int argc, char *argv[]) path = argv[optind]; } - if (create) { - char *name; + root = of_get_root_node(); + if (!root) { + printf("root node not set\n"); + return -ENOENT; + } + if (create) { if (!path) return COMMAND_ERROR_USAGE; - name = xstrdup(basename(path)); - path = dirname(path); - - node = of_find_node_by_path(path); - if (!node) { - printf("Cannot find nodepath %s\n", path); - free(name); - return -ENOENT; - } - - debug("create node \"%s\" \"%s\"\n", path, name); - - of_new_node(node, name); - - free(name); + node = of_create_node(root, path); + if (!node) + return -EINVAL; return 0; } |