summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-09-05 10:37:54 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-05 10:37:54 +0200
commit10169a04ca42997c8bbd3ce67bac61030336a848 (patch)
tree894c096f54ac1a4c185acd137aa1f4b24f367005 /commands
parent88e132b2a8a6b50c19d6384403326081ef791d58 (diff)
parentda19582070da7918c901c26d001c6d0114291461 (diff)
downloadbarebox-10169a04ca42997c8bbd3ce67bac61030336a848.tar.gz
barebox-10169a04ca42997c8bbd3ce67bac61030336a848.tar.xz
Merge branch 'for-next/of'
Diffstat (limited to 'commands')
-rw-r--r--commands/of_property.c36
-rw-r--r--commands/oftree.c2
2 files changed, 34 insertions, 4 deletions
diff --git a/commands/of_property.c b/commands/of_property.c
index 8ffe30b25f..4518c72528 100644
--- a/commands/of_property.c
+++ b/commands/of_property.c
@@ -55,7 +55,36 @@ static int of_parse_prop_cells(char * const *newval, int count, char *data, int
}
cp = newp;
- tmp = simple_strtoul(cp, &newp, 0);
+
+ if (isdigit(*cp)) {
+ tmp = simple_strtoul(cp, &newp, 0);
+ } else {
+ struct device_node *n;
+ char *str;
+ int len = 0;
+
+ str = cp;
+ while (*str && *str != '>' && *str != ' ') {
+ str++;
+ len++;
+ }
+
+ str = xzalloc(len + 1);
+ strncpy(str, cp, len);
+
+ n = of_find_node_by_path_or_alias(NULL, str);
+ if (!n)
+ printf("Cannot find node '%s'\n", str);
+
+ free(str);
+
+ if (!n)
+ return -EINVAL;
+
+ tmp = of_node_create_phandle(n);
+ newp += len;
+ }
+
*(__be32 *)data = __cpu_to_be32(tmp);
data += 4;
*len += 4;
@@ -196,7 +225,7 @@ static int do_of_property(int argc, char *argv[])
if (optind < argc) {
path = argv[optind];
- node = of_find_node_by_path(path);
+ node = of_find_node_by_path_or_alias(NULL, path);
if (!node) {
printf("Cannot find nodepath %s\n", path);
return -ENOENT;
@@ -276,7 +305,8 @@ BAREBOX_CMD_HELP_USAGE("of_property [OPTIONS] [NODE] [PROPERTY] [VALUES]\n")
BAREBOX_CMD_HELP_OPT ("-s", "set property to value\n")
BAREBOX_CMD_HELP_OPT ("-d", "delete property\n")
BAREBOX_CMD_HELP_TEXT ("\nvalid formats for values:\n")
-BAREBOX_CMD_HELP_TEXT ("<0x00112233 4 05> - an array of cells\n")
+BAREBOX_CMD_HELP_TEXT ("<0x00112233 4 05> - an array of cells. cells not beginning with a digit are\n")
+BAREBOX_CMD_HELP_TEXT (" interpreted as node pathes and converted to phandles\n")
BAREBOX_CMD_HELP_TEXT ("[00 11 22 .. nn] - byte stream\n")
BAREBOX_CMD_HELP_TEXT ("If the value does not start with '<' or '[' it is interpreted as strings\n")
BAREBOX_CMD_HELP_END
diff --git a/commands/oftree.c b/commands/oftree.c
index 00e54dcd7e..475f0199ba 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -164,7 +164,7 @@ static int do_oftree(int argc, char *argv[])
of_print_nodes(root, 0);
of_delete_node(root);
} else {
- struct device_node *n = of_find_node_by_path(node);
+ struct device_node *n = of_find_node_by_path_or_alias(NULL, node);
if (!n) {
ret = -ENOENT;
goto out;