* [PATCH] devicetree command changes
@ 2014-05-19 20:59 Sascha Hauer
2014-05-19 20:59 ` [PATCH 1/6] complete: Fix completion after options Sascha Hauer
` (5 more replies)
0 siblings, 6 replies; 17+ messages in thread
From: Sascha Hauer @ 2014-05-19 20:59 UTC (permalink / raw)
To: barebox
This series has some changes to the devicetree commands:
- Add devicetree completion
- Add a dedicated of_dump command to make dumping nodes easier
Sascha
----------------------------------------------------------------
Sascha Hauer (6):
complete: Fix completion after options
complete: Add devicetree completion
commands: add of_dump command
oftree: remove dump support
of: Drop devicetree merge support
oftree command: make devicetree file optargs to -l/-s
arch/arm/boards/highbank/init.c | 2 +-
arch/arm/cpu/dtb.c | 2 +-
arch/arm/lib/bootm.c | 2 +-
arch/mips/boot/dtb.c | 2 +-
commands/Kconfig | 15 +++++-
commands/Makefile | 1 +
commands/of_dump.c | 108 ++++++++++++++++++++++++++++++++++++++++
commands/of_node.c | 2 +
commands/of_property.c | 2 +
commands/oftree.c | 101 ++++++++-----------------------------
common/blspec.c | 2 +-
common/bootm.c | 2 +-
common/complete.c | 76 ++++++++++++++++++++++++++++
drivers/of/fdt.c | 44 +++++-----------
include/complete.h | 5 +-
include/of.h | 2 +-
16 files changed, 246 insertions(+), 122 deletions(-)
create mode 100644 commands/of_dump.c
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/6] complete: Fix completion after options
2014-05-19 20:59 [PATCH] devicetree command changes Sascha Hauer
@ 2014-05-19 20:59 ` Sascha Hauer
2014-05-19 20:59 ` [PATCH 2/6] complete: Add devicetree completion Sascha Hauer
` (4 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Sascha Hauer @ 2014-05-19 20:59 UTC (permalink / raw)
To: barebox
the command specific complete callbacks only work when no
option is typed already. For example "devinfo <tab><tab>"
correctly completes the devices, but "devinfo -x <tab><tab>"
does nothing. That is because the options are passed to
the input string of the completion handlers. Skip the option
string by finding the last space in the input string. This
is not perfect since "devinfo -f<tab><tab>" still does not
work, but it's better than what we have now.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/complete.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/common/complete.c b/common/complete.c
index 9206ef0..368321f 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -277,11 +277,16 @@ static char* cmd_complete_lookup(struct string_list *sl, char *instr)
int len;
int ret = COMPLETE_END;
char *res = NULL;
+ char *t;
for_each_command(cmdtp) {
len = strlen(cmdtp->name);
if (!strncmp(instr, cmdtp->name, len) && instr[len] == ' ') {
instr += len + 1;
+ t = strrchr(instr, ' ');
+ if (t)
+ instr = t + 1;
+
if (cmdtp->complete) {
ret = cmdtp->complete(sl, instr);
res = instr;
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 2/6] complete: Add devicetree completion
2014-05-19 20:59 [PATCH] devicetree command changes Sascha Hauer
2014-05-19 20:59 ` [PATCH 1/6] complete: Fix completion after options Sascha Hauer
@ 2014-05-19 20:59 ` Sascha Hauer
2014-05-19 20:59 ` [PATCH 3/6] commands: add of_dump command Sascha Hauer
` (3 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Sascha Hauer @ 2014-05-19 20:59 UTC (permalink / raw)
To: barebox
The of_* commands take devicetree nodes as parameters. Add a
devicetree completion function to ease passing nodes to these
commands.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/of_node.c | 2 ++
commands/of_property.c | 2 ++
commands/oftree.c | 2 ++
common/complete.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/complete.h | 5 +++-
5 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/commands/of_node.c b/commands/of_node.c
index 901da88..4962e52 100644
--- a/commands/of_node.c
+++ b/commands/of_node.c
@@ -21,6 +21,7 @@
#include <environment.h>
#include <fdt.h>
#include <of.h>
+#include <complete.h>
#include <command.h>
#include <fs.h>
#include <malloc.h>
@@ -104,5 +105,6 @@ BAREBOX_CMD_START(of_node)
BAREBOX_CMD_DESC("create/delete nodes in the device tree")
BAREBOX_CMD_OPTS("[-cd] NODE NAME")
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
+ BAREBOX_CMD_COMPLETE(devicetree_complete)
BAREBOX_CMD_HELP(cmd_of_node_help)
BAREBOX_CMD_END
diff --git a/commands/of_property.c b/commands/of_property.c
index f9f35b2..e0154fc 100644
--- a/commands/of_property.c
+++ b/commands/of_property.c
@@ -24,6 +24,7 @@
#include <command.h>
#include <fs.h>
#include <malloc.h>
+#include <complete.h>
#include <linux/ctype.h>
#include <asm/byteorder.h>
#include <errno.h>
@@ -317,5 +318,6 @@ BAREBOX_CMD_START(of_property)
BAREBOX_CMD_DESC("handle device tree properties")
BAREBOX_CMD_OPTS("[-sd] NODE [PROPERTY] [VALUES]")
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
+ BAREBOX_CMD_COMPLETE(devicetree_complete)
BAREBOX_CMD_HELP(cmd_of_property_help)
BAREBOX_CMD_END
diff --git a/commands/oftree.c b/commands/oftree.c
index 3253cf1..16648d6 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -37,6 +37,7 @@
#include <getopt.h>
#include <init.h>
#include <fcntl.h>
+#include <complete.h>
static int do_oftree(int argc, char *argv[])
{
@@ -207,4 +208,5 @@ BAREBOX_CMD_START(oftree)
BAREBOX_CMD_OPTS("[-lpfdn] [DTB]")
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
BAREBOX_CMD_HELP(cmd_oftree_help)
+ BAREBOX_CMD_COMPLETE(devicetree_file_complete)
BAREBOX_CMD_END
diff --git a/common/complete.c b/common/complete.c
index 368321f..5b71f03 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -204,6 +204,77 @@ int command_var_complete(struct string_list *sl, char *instr)
}
EXPORT_SYMBOL(command_var_complete);
+int devicetree_alias_complete(struct string_list *sl, char *instr)
+{
+ struct device_node *aliases;
+ struct property *p;
+
+ aliases = of_find_node_by_path("/aliases");
+ if (!aliases)
+ return 0;
+
+ list_for_each_entry(p, &aliases->properties, list) {
+ if (strncmp(instr, p->name, strlen(instr)))
+ continue;
+
+ string_list_add_asprintf(sl, "%s ", p->name);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(devicetree_alias_complete);
+
+int devicetree_nodepath_complete(struct string_list *sl, char *instr)
+{
+ struct device_node *node, *child;
+ char *dirn, *base;
+ char *path = strdup(instr);
+
+ if (*instr == '/') {
+ dirn = dirname(path);
+ base = basename(instr);
+ node = of_find_node_by_path(dirn);
+ if (!node)
+ goto out;
+ } else if (!*instr) {
+ node = of_get_root_node();
+ if (!node)
+ goto out;
+ base = "";
+ } else {
+ goto out;
+ }
+
+ for_each_child_of_node(node, child) {
+ if (strncmp(base, child->name, strlen(base)))
+ continue;
+ string_list_add_asprintf(sl, "%s/", child->full_name);
+ }
+out:
+ free(path);
+
+ return 0;
+}
+EXPORT_SYMBOL(devicetree_nodepath_complete);
+
+int devicetree_complete(struct string_list *sl, char *instr)
+{
+ devicetree_nodepath_complete(sl, instr);
+ devicetree_alias_complete(sl, instr);
+
+ return 0;
+}
+EXPORT_SYMBOL(devicetree_complete);
+
+int devicetree_file_complete(struct string_list *sl, char *instr)
+{
+ devicetree_complete(sl, instr);
+ file_complete(sl, instr, 0);
+
+ return 0;
+}
+EXPORT_SYMBOL(devicetree_file_complete);
+
static int env_param_complete(struct string_list *sl, char *instr, int eval)
{
struct device_d *dev;
diff --git a/include/complete.h b/include/complete.h
index 33b848c..491ba66 100644
--- a/include/complete.h
+++ b/include/complete.h
@@ -17,6 +17,9 @@ int empty_complete(struct string_list *sl, char *instr);
int eth_complete(struct string_list *sl, char *instr);
int command_var_complete(struct string_list *sl, char *instr);
int devfs_partition_complete(struct string_list *sl, char *instr);
+int devicetree_alias_complete(struct string_list *sl, char *instr);
+int devicetree_nodepath_complete(struct string_list *sl, char *instr);
+int devicetree_complete(struct string_list *sl, char *instr);
+int devicetree_file_complete(struct string_list *sl, char *instr);
#endif /* __COMPLETE_ */
-
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 3/6] commands: add of_dump command
2014-05-19 20:59 [PATCH] devicetree command changes Sascha Hauer
2014-05-19 20:59 ` [PATCH 1/6] complete: Fix completion after options Sascha Hauer
2014-05-19 20:59 ` [PATCH 2/6] complete: Add devicetree completion Sascha Hauer
@ 2014-05-19 20:59 ` Sascha Hauer
2014-05-21 13:17 ` Holger Schurig
2014-05-19 20:59 ` [PATCH 4/6] oftree: remove dump support Sascha Hauer
` (2 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Sascha Hauer @ 2014-05-19 20:59 UTC (permalink / raw)
To: barebox
The oftree command is overloaded. This adds a dedicated command
which only dumps devicetrees to the console so that the corresponding
functionality in the oftree command can be removed in the next step.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/Kconfig | 13 +++++++
commands/Makefile | 1 +
commands/of_dump.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 122 insertions(+)
create mode 100644 commands/of_dump.c
diff --git a/commands/Kconfig b/commands/Kconfig
index 02f0931..381f3fd 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1886,6 +1886,19 @@ config CMD_LSMOD
help
List loaded barebox modules.
+config CMD_OF_DUMP
+ tristate
+ select OFTREE
+ prompt "of_dump"
+ default y if CMD_OFTREE
+ help
+ dump devicetree nodes to the console
+
+ Usage: of_dump [-f] [NODE]
+
+ Options:
+ -f <dtb> work on <dtb> instead of internal devicetree
+
config CMD_OF_NODE
tristate
select OFTREE
diff --git a/commands/Makefile b/commands/Makefile
index 2373ccf..030a906 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -75,6 +75,7 @@ obj-$(CONFIG_CMD_TIME) += time.o
obj-$(CONFIG_CMD_OFTREE) += oftree.o
obj-$(CONFIG_CMD_OF_PROPERTY) += of_property.o
obj-$(CONFIG_CMD_OF_NODE) += of_node.o
+obj-$(CONFIG_CMD_OF_DUMP) += of_dump.o
obj-$(CONFIG_CMD_MAGICVAR) += magicvar.o
obj-$(CONFIG_CMD_IOMEM) += iomemport.o
obj-$(CONFIG_CMD_LINUX_EXEC) += linux_exec.o
diff --git a/commands/of_dump.c b/commands/of_dump.c
new file mode 100644
index 0000000..0ed47bb
--- /dev/null
+++ b/commands/of_dump.c
@@ -0,0 +1,108 @@
+/*
+ * of_dump.c - dump devicetrees to the console
+ *
+ * Copyright (c) 2014 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <fdt.h>
+#include <of.h>
+#include <command.h>
+#include <fs.h>
+#include <malloc.h>
+#include <complete.h>
+#include <linux/ctype.h>
+#include <asm/byteorder.h>
+#include <errno.h>
+#include <getopt.h>
+#include <linux/err.h>
+
+static int do_of_dump(int argc, char *argv[])
+{
+ int opt;
+ int ret;
+ struct device_node *root = NULL, *node, *of_free = NULL;
+ char *dtbfile = NULL;
+ size_t size;
+ const char *nodename;
+
+ while ((opt = getopt(argc, argv, "f:")) > 0) {
+ switch (opt) {
+ case 'f':
+ dtbfile = optarg;
+ break;
+ default:
+ return COMMAND_ERROR_USAGE;
+ }
+ }
+
+ if (optind == argc)
+ nodename = "/";
+ else
+ nodename = argv[optind];
+
+ if (dtbfile) {
+ void *fdt;
+
+ fdt = read_file(dtbfile, &size);
+ if (!fdt) {
+ printf("unable to read %s: %s\n", dtbfile, strerror(errno));
+ return -errno;
+ }
+
+ root = of_unflatten_dtb(NULL, fdt);
+
+ free(fdt);
+
+ if (IS_ERR(root)) {
+ ret = PTR_ERR(root);
+ goto out;
+ }
+
+ of_free = root;
+ } else {
+ root = of_get_root_node();
+ }
+
+ node = of_find_node_by_path_or_alias(root, nodename);
+ if (!node) {
+ printf("Cannot find nodepath %s\n", nodename);
+ ret = -ENOENT;
+ goto out;
+ }
+
+ of_print_nodes(node, 0);
+
+out:
+ if (of_free)
+ of_delete_node(of_free);
+
+ return 0;
+}
+
+BAREBOX_CMD_HELP_START(of_dump)
+BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-f <dtb>", "work on <dtb> instead of internal devicetree\n")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(of_dump)
+ .cmd = do_of_dump,
+ BAREBOX_CMD_DESC("dump devicetree nodes")
+ BAREBOX_CMD_OPTS("[-f]")
+ BAREBOX_CMD_GROUP(CMD_GRP_MISC)
+ BAREBOX_CMD_COMPLETE(devicetree_file_complete)
+ BAREBOX_CMD_HELP(cmd_of_dump_help)
+BAREBOX_CMD_END
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 4/6] oftree: remove dump support
2014-05-19 20:59 [PATCH] devicetree command changes Sascha Hauer
` (2 preceding siblings ...)
2014-05-19 20:59 ` [PATCH 3/6] commands: add of_dump command Sascha Hauer
@ 2014-05-19 20:59 ` Sascha Hauer
2014-05-20 8:01 ` Alexander Aring
2014-05-19 20:59 ` [PATCH 5/6] of: Drop devicetree merge support Sascha Hauer
2014-05-19 20:59 ` [PATCH 6/6] oftree command: make devicetree file optargs to -l/-s Sascha Hauer
5 siblings, 1 reply; 17+ messages in thread
From: Sascha Hauer @ 2014-05-19 20:59 UTC (permalink / raw)
To: barebox
This can now be done with the of_dump command.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/Kconfig | 2 --
commands/oftree.c | 42 +++---------------------------------------
2 files changed, 3 insertions(+), 41 deletions(-)
diff --git a/commands/Kconfig b/commands/Kconfig
index 381f3fd..6043cb6 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1944,8 +1944,6 @@ config CMD_OFTREE
-l Load DTB to internal device tree
-p probe devices from stored device tree
-f free stored device tree
- -d dump device tree from DTB or the parsed tree if no DTB is given
- -n NODE specify root device NODE to dump for -d
config CMD_TIME
bool "time"
diff --git a/commands/oftree.c b/commands/oftree.c
index 16648d6..db31d59 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -46,8 +46,6 @@ static int do_oftree(int argc, char *argv[])
int size;
int opt;
char *file = NULL;
- const char *node = "/";
- int dump = 0;
int probe = 0;
int load = 0;
int save = 0;
@@ -55,14 +53,11 @@ static int do_oftree(int argc, char *argv[])
int ret;
struct device_node *n, *root;
- while ((opt = getopt(argc, argv, "dpfn:ls")) > 0) {
+ while ((opt = getopt(argc, argv, "pfl:s:")) > 0) {
switch (opt) {
case 'l':
load = 1;
break;
- case 'd':
- dump = 1;
- break;
case 'p':
if (IS_ENABLED(CONFIG_OFDEVICE)) {
probe = 1;
@@ -74,9 +69,6 @@ static int do_oftree(int argc, char *argv[])
case 'f':
free_of = 1;
break;
- case 'n':
- node = optarg;
- break;
case 's':
save = 1;
break;
@@ -96,7 +88,7 @@ static int do_oftree(int argc, char *argv[])
if (optind < argc)
file = argv[optind];
- if (!dump && !probe && !load && !save)
+ if (!probe && !load && !save)
return COMMAND_ERROR_USAGE;
if (save) {
@@ -155,31 +147,6 @@ static int do_oftree(int argc, char *argv[])
}
}
- if (dump) {
- if (fdt) {
- root = of_unflatten_dtb(NULL, fdt);
- if (IS_ERR(root)) {
- printf("parse oftree: %s\n", strerror(-PTR_ERR(root)));
- ret = 1;
- goto out;
- }
- of_print_nodes(root, 0);
- of_delete_node(root);
- } else {
- struct device_node *n = of_find_node_by_path_or_alias(NULL, node);
- if (!n) {
- ret = -ENOENT;
- goto out;
- }
-
- of_print_nodes(n, 0);
- }
-
- ret = 0;
-
- goto out;
- }
-
if (probe) {
ret = of_probe();
if (ret)
@@ -198,15 +165,12 @@ BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT ("-l", "Load DTB to internal device tree")
BAREBOX_CMD_HELP_OPT ("-p", "probe devices from stored device tree")
BAREBOX_CMD_HELP_OPT ("-f", "free stored device tree")
-BAREBOX_CMD_HELP_OPT ("-d", "dump device tree from DTB or the parsed tree if no DTB is given")
-BAREBOX_CMD_HELP_OPT ("-n NODE", "specify root device NODE to dump for -d")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(oftree)
.cmd = do_oftree,
BAREBOX_CMD_DESC("handle device trees")
- BAREBOX_CMD_OPTS("[-lpfdn] [DTB]")
+ BAREBOX_CMD_OPTS("[-lpf] [DTB]")
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
BAREBOX_CMD_HELP(cmd_oftree_help)
- BAREBOX_CMD_COMPLETE(devicetree_file_complete)
BAREBOX_CMD_END
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 5/6] of: Drop devicetree merge support
2014-05-19 20:59 [PATCH] devicetree command changes Sascha Hauer
` (3 preceding siblings ...)
2014-05-19 20:59 ` [PATCH 4/6] oftree: remove dump support Sascha Hauer
@ 2014-05-19 20:59 ` Sascha Hauer
2014-05-20 15:08 ` Sebastian Hesselbarth
2014-05-21 13:24 ` Holger Schurig
2014-05-19 20:59 ` [PATCH 6/6] oftree command: make devicetree file optargs to -l/-s Sascha Hauer
5 siblings, 2 replies; 17+ messages in thread
From: Sascha Hauer @ 2014-05-19 20:59 UTC (permalink / raw)
To: barebox
I assume I am the only person knowing that barebox is able to
merge devicetrees. This feature seems broken for a while now since
trying to merge devicetress results in:
unflatten: too many end nodes
Remove this feature to save the complexity.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/boards/highbank/init.c | 2 +-
arch/arm/cpu/dtb.c | 2 +-
arch/arm/lib/bootm.c | 2 +-
arch/mips/boot/dtb.c | 2 +-
commands/of_dump.c | 2 +-
commands/oftree.c | 9 +++------
common/blspec.c | 2 +-
common/bootm.c | 2 +-
drivers/of/fdt.c | 44 +++++++++++------------------------------
include/of.h | 2 +-
10 files changed, 23 insertions(+), 46 deletions(-)
diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
index d5d341a..7b4f963 100644
--- a/arch/arm/boards/highbank/init.c
+++ b/arch/arm/boards/highbank/init.c
@@ -76,7 +76,7 @@ static int highbank_mem_init(void)
/* load by the firmware at 0x1000 */
fdt = IOMEM(FIRMWARE_DTB_BASE);
- root = of_unflatten_dtb(NULL, fdt);
+ root = of_unflatten_dtb(fdt);
if (!root) {
pr_warn("no dtb found at 0x1000 use default configuration\n");
fdt = NULL;
diff --git a/arch/arm/cpu/dtb.c b/arch/arm/cpu/dtb.c
index a5881dd..abc3ccb 100644
--- a/arch/arm/cpu/dtb.c
+++ b/arch/arm/cpu/dtb.c
@@ -47,7 +47,7 @@ static int of_arm_init(void)
return 0;
}
- root = of_unflatten_dtb(NULL, fdt);
+ root = of_unflatten_dtb(fdt);
if (root) {
of_set_root_node(root);
if (IS_ENABLED(CONFIG_OFDEVICE))
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 8035468..1d69052 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -215,7 +215,7 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
}
if (IS_BUILTIN(CONFIG_OFTREE)) {
- data->of_root_node = of_unflatten_dtb(NULL, oftree);
+ data->of_root_node = of_unflatten_dtb(oftree);
if (!data->of_root_node) {
pr_err("unable to unflatten devicetree\n");
ret = -EINVAL;
diff --git a/arch/mips/boot/dtb.c b/arch/mips/boot/dtb.c
index c1962bf..23d8979 100644
--- a/arch/mips/boot/dtb.c
+++ b/arch/mips/boot/dtb.c
@@ -48,7 +48,7 @@ static int of_mips_init(void)
if (root)
return 0;
- root = of_unflatten_dtb(NULL, __dtb_start);
+ root = of_unflatten_dtb(__dtb_start);
if (root) {
pr_debug("using internal DTB\n");
of_set_root_node(root);
diff --git a/commands/of_dump.c b/commands/of_dump.c
index 0ed47bb..1aefcc7 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -63,7 +63,7 @@ static int do_of_dump(int argc, char *argv[])
return -errno;
}
- root = of_unflatten_dtb(NULL, fdt);
+ root = of_unflatten_dtb(fdt);
free(fdt);
diff --git a/commands/oftree.c b/commands/oftree.c
index db31d59..2c45b93 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -51,7 +51,7 @@ static int do_oftree(int argc, char *argv[])
int save = 0;
int free_of = 0;
int ret;
- struct device_node *n, *root;
+ struct device_node *root;
while ((opt = getopt(argc, argv, "pfl:s:")) > 0) {
switch (opt) {
@@ -130,16 +130,13 @@ static int do_oftree(int argc, char *argv[])
goto out;
}
- n = of_get_root_node();
-
- root = of_unflatten_dtb(n, fdt);
+ root = of_unflatten_dtb(fdt);
if (IS_ERR(root))
ret = PTR_ERR(root);
else
ret = 0;
- if (!n)
- ret = of_set_root_node(root);
+ ret = of_set_root_node(root);
if (ret) {
printf("parse oftree: %s\n", strerror(-ret));
diff --git a/common/blspec.c b/common/blspec.c
index f165b77..9314eea 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -281,7 +281,7 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
goto out;
}
- root = of_unflatten_dtb(NULL, fdt);
+ root = of_unflatten_dtb(fdt);
if (IS_ERR(root)) {
ret = PTR_ERR(root);
goto out;
diff --git a/common/bootm.c b/common/bootm.c
index 12d3ee0..b250bd1 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -297,7 +297,7 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
return -EINVAL;
}
- data->of_root_node = of_unflatten_dtb(NULL, fdt);
+ data->of_root_node = of_unflatten_dtb(fdt);
if (!data->of_root_node) {
pr_err("unable to unflatten devicetree\n");
free(fdt);
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3dc5d47..8e4c775 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -54,20 +54,20 @@ static inline char *dt_string(struct fdt_header *f, char *strstart, uint32_t ofs
* Parse a flat device tree binary blob and return a pointer to the
* unflattened tree.
*/
-struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
+struct device_node *of_unflatten_dtb(void *infdt)
{
const void *nodep; /* property node pointer */
uint32_t tag; /* tag */
int len; /* length of the property */
const struct fdt_property *fdt_prop;
const char *pathp, *name;
- struct device_node *node = NULL;
+ struct device_node *root, *node = NULL;
struct property *p;
uint32_t dt_struct;
struct fdt_node_header *fnh;
void *dt_strings;
struct fdt_header f;
- int ret, merge = 0;
+ int ret;
unsigned int maxlen;
struct fdt_header *fdt = infdt;
@@ -100,14 +100,9 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
dt_struct = f.off_dt_struct;
dt_strings = (void *)fdt + f.off_dt_strings;
- if (root) {
- pr_debug("unflatten: merging into existing tree\n");
- merge = 1;
- } else {
- root = of_new_node(NULL, NULL);
- if (!root)
- return ERR_PTR(-ENOMEM);
- }
+ root = of_new_node(NULL, NULL);
+ if (!root)
+ return ERR_PTR(-ENOMEM);
while (1) {
tag = be32_to_cpu(*(uint32_t *)(infdt + dt_struct));
@@ -132,15 +127,10 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
goto err;
}
- if (!node) {
+ if (!node)
node = root;
- } else {
- if (merge)
- node = of_get_child_by_name(node,
- pathp);
- if (!merge || !node)
- node = of_new_node(node, pathp);
- }
+ else
+ node = of_new_node(node, pathp);
break;
@@ -179,19 +169,9 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
goto err;
}
- p = NULL;
- if (merge)
- p = of_find_property(node, name, NULL);
- if (merge && p) {
- free(p->value);
- p->value = xzalloc(len);
- p->length = len;
- memcpy(p->value, nodep, len);
- } else {
- p = of_new_property(node, name, nodep, len);
- if (!strcmp(name, "phandle") && len == 4)
- node->phandle = be32_to_cpup(p->value);
- }
+ p = of_new_property(node, name, nodep, len);
+ if (!strcmp(name, "phandle") && len == 4)
+ node->phandle = be32_to_cpup(p->value);
break;
diff --git a/include/of.h b/include/of.h
index 3183428..e6993fd 100644
--- a/include/of.h
+++ b/include/of.h
@@ -98,7 +98,7 @@ void of_print_cmdline(struct device_node *root);
void of_print_nodes(struct device_node *node, int indent);
int of_probe(void);
int of_parse_dtb(struct fdt_header *fdt);
-struct device_node *of_unflatten_dtb(struct device_node *root, void *fdt);
+struct device_node *of_unflatten_dtb(void *fdt);
struct cdev;
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 6/6] oftree command: make devicetree file optargs to -l/-s
2014-05-19 20:59 [PATCH] devicetree command changes Sascha Hauer
` (4 preceding siblings ...)
2014-05-19 20:59 ` [PATCH 5/6] of: Drop devicetree merge support Sascha Hauer
@ 2014-05-19 20:59 ` Sascha Hauer
5 siblings, 0 replies; 17+ messages in thread
From: Sascha Hauer @ 2014-05-19 20:59 UTC (permalink / raw)
To: barebox
When loading or saving a devicetree it seems logical to add the
filename to the option specifying the command. This is also slightly
easier to parse.
While at it add missing documentation for the -s option.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/oftree.c | 54 ++++++++++++++++--------------------------------------
1 file changed, 16 insertions(+), 38 deletions(-)
diff --git a/commands/oftree.c b/commands/oftree.c
index 2c45b93..a3b0e04 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -42,13 +42,11 @@
static int do_oftree(int argc, char *argv[])
{
struct fdt_header *fdt = NULL;
- void *fdt_free = NULL;
int size;
int opt;
- char *file = NULL;
int probe = 0;
- int load = 0;
- int save = 0;
+ char *load = NULL;
+ char *save = NULL;
int free_of = 0;
int ret;
struct device_node *root;
@@ -56,7 +54,7 @@ static int do_oftree(int argc, char *argv[])
while ((opt = getopt(argc, argv, "pfl:s:")) > 0) {
switch (opt) {
case 'l':
- load = 1;
+ load = optarg;
break;
case 'p':
if (IS_ENABLED(CONFIG_OFDEVICE)) {
@@ -70,7 +68,7 @@ static int do_oftree(int argc, char *argv[])
free_of = 1;
break;
case 's':
- save = 1;
+ save = optarg;
break;
}
}
@@ -85,20 +83,10 @@ static int do_oftree(int argc, char *argv[])
return 0;
}
- if (optind < argc)
- file = argv[optind];
-
if (!probe && !load && !save)
return COMMAND_ERROR_USAGE;
if (save) {
- if (!file) {
- printf("no file given\n");
- ret = -ENOENT;
-
- goto out;
- }
-
fdt = of_get_fixed_tree(NULL);
if (!fdt) {
printf("no devicetree available\n");
@@ -107,39 +95,29 @@ static int do_oftree(int argc, char *argv[])
goto out;
}
- ret = write_file(file, fdt, fdt32_to_cpu(fdt->totalsize));
+ ret = write_file(save, fdt, fdt32_to_cpu(fdt->totalsize));
goto out;
}
- if (file) {
- fdt = read_file(file, &size);
+ if (load) {
+ fdt = read_file(load, &size);
if (!fdt) {
- printf("unable to read %s\n", file);
+ printf("unable to read %s\n", load);
return 1;
}
- fdt_free = fdt;
- }
-
- if (load) {
- if (!fdt) {
- printf("no fdt given\n");
- ret = -ENOENT;
+ root = of_unflatten_dtb(fdt);
- goto out;
- }
+ free(fdt);
- root = of_unflatten_dtb(fdt);
if (IS_ERR(root))
- ret = PTR_ERR(root);
- else
- ret = 0;
+ return PTR_ERR(root);
ret = of_set_root_node(root);
-
if (ret) {
- printf("parse oftree: %s\n", strerror(-ret));
+ printf("setting root node failed: %s\n", strerror(-ret));
+ of_delete_node(root);
goto out;
}
}
@@ -152,14 +130,14 @@ static int do_oftree(int argc, char *argv[])
ret = 0;
out:
- free(fdt_free);
return ret;
}
BAREBOX_CMD_HELP_START(oftree)
BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT ("-l", "Load DTB to internal device tree")
+BAREBOX_CMD_HELP_OPT ("-l <DTB>", "Load <DTB> to internal devicetree\n")
+BAREBOX_CMD_HELP_OPT ("-s <DTB>", "save internal devicetree to <DTB>\n")
BAREBOX_CMD_HELP_OPT ("-p", "probe devices from stored device tree")
BAREBOX_CMD_HELP_OPT ("-f", "free stored device tree")
BAREBOX_CMD_HELP_END
@@ -167,7 +145,7 @@ BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(oftree)
.cmd = do_oftree,
BAREBOX_CMD_DESC("handle device trees")
- BAREBOX_CMD_OPTS("[-lpf] [DTB]")
+ BAREBOX_CMD_OPTS("[-lpfs]")
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
BAREBOX_CMD_HELP(cmd_oftree_help)
BAREBOX_CMD_END
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/6] oftree: remove dump support
2014-05-19 20:59 ` [PATCH 4/6] oftree: remove dump support Sascha Hauer
@ 2014-05-20 8:01 ` Alexander Aring
2014-05-20 8:03 ` Alexander Aring
0 siblings, 1 reply; 17+ messages in thread
From: Alexander Aring @ 2014-05-20 8:01 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Hi Sascha,
On Mon, May 19, 2014 at 10:59:42PM +0200, Sascha Hauer wrote:
> This can now be done with the of_dump command.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> commands/Kconfig | 2 --
> commands/oftree.c | 42 +++---------------------------------------
> 2 files changed, 3 insertions(+), 41 deletions(-)
>
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 381f3fd..6043cb6 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -1944,8 +1944,6 @@ config CMD_OFTREE
> -l Load DTB to internal device tree
> -p probe devices from stored device tree
> -f free stored device tree
> - -d dump device tree from DTB or the parsed tree if no DTB is given
> - -n NODE specify root device NODE to dump for -d
>
> config CMD_TIME
> bool "time"
> diff --git a/commands/oftree.c b/commands/oftree.c
> index 16648d6..db31d59 100644
> --- a/commands/oftree.c
> +++ b/commands/oftree.c
> @@ -46,8 +46,6 @@ static int do_oftree(int argc, char *argv[])
> int size;
> int opt;
> char *file = NULL;
> - const char *node = "/";
> - int dump = 0;
> int probe = 0;
> int load = 0;
> int save = 0;
> @@ -55,14 +53,11 @@ static int do_oftree(int argc, char *argv[])
> int ret;
> struct device_node *n, *root;
>
> - while ((opt = getopt(argc, argv, "dpfn:ls")) > 0) {
> + while ((opt = getopt(argc, argv, "pfl:s:")) > 0) {
Are you sure this optstring conversion is correct? Before there was
no optargs for -l and -s.
- Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/6] oftree: remove dump support
2014-05-20 8:01 ` Alexander Aring
@ 2014-05-20 8:03 ` Alexander Aring
2014-05-20 9:08 ` Sascha Hauer
0 siblings, 1 reply; 17+ messages in thread
From: Alexander Aring @ 2014-05-20 8:03 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On Tue, May 20, 2014 at 10:01:01AM +0200, Alexander Aring wrote:
> Hi Sascha,
>
> On Mon, May 19, 2014 at 10:59:42PM +0200, Sascha Hauer wrote:
> > This can now be done with the of_dump command.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> > commands/Kconfig | 2 --
> > commands/oftree.c | 42 +++---------------------------------------
> > 2 files changed, 3 insertions(+), 41 deletions(-)
> >
> > diff --git a/commands/Kconfig b/commands/Kconfig
> > index 381f3fd..6043cb6 100644
> > --- a/commands/Kconfig
> > +++ b/commands/Kconfig
> > @@ -1944,8 +1944,6 @@ config CMD_OFTREE
> > -l Load DTB to internal device tree
> > -p probe devices from stored device tree
> > -f free stored device tree
> > - -d dump device tree from DTB or the parsed tree if no DTB is given
> > - -n NODE specify root device NODE to dump for -d
> >
> > config CMD_TIME
> > bool "time"
> > diff --git a/commands/oftree.c b/commands/oftree.c
> > index 16648d6..db31d59 100644
> > --- a/commands/oftree.c
> > +++ b/commands/oftree.c
> > @@ -46,8 +46,6 @@ static int do_oftree(int argc, char *argv[])
> > int size;
> > int opt;
> > char *file = NULL;
> > - const char *node = "/";
> > - int dump = 0;
> > int probe = 0;
> > int load = 0;
> > int save = 0;
> > @@ -55,14 +53,11 @@ static int do_oftree(int argc, char *argv[])
> > int ret;
> > struct device_node *n, *root;
> >
> > - while ((opt = getopt(argc, argv, "dpfn:ls")) > 0) {
> > + while ((opt = getopt(argc, argv, "pfl:s:")) > 0) {
>
> Are you sure this optstring conversion is correct? Before there was
> no optargs for -l and -s.
Saw this right now in patch 6/6, sorry.
- Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/6] oftree: remove dump support
2014-05-20 8:03 ` Alexander Aring
@ 2014-05-20 9:08 ` Sascha Hauer
0 siblings, 0 replies; 17+ messages in thread
From: Sascha Hauer @ 2014-05-20 9:08 UTC (permalink / raw)
To: Alexander Aring; +Cc: barebox
On Tue, May 20, 2014 at 10:03:08AM +0200, Alexander Aring wrote:
> On Tue, May 20, 2014 at 10:01:01AM +0200, Alexander Aring wrote:
> > Hi Sascha,
> >
> > On Mon, May 19, 2014 at 10:59:42PM +0200, Sascha Hauer wrote:
> > > This can now be done with the of_dump command.
> > >
> > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > ---
> > > commands/Kconfig | 2 --
> > > commands/oftree.c | 42 +++---------------------------------------
> > > 2 files changed, 3 insertions(+), 41 deletions(-)
> > >
> > > diff --git a/commands/Kconfig b/commands/Kconfig
> > > index 381f3fd..6043cb6 100644
> > > --- a/commands/Kconfig
> > > +++ b/commands/Kconfig
> > > @@ -1944,8 +1944,6 @@ config CMD_OFTREE
> > > -l Load DTB to internal device tree
> > > -p probe devices from stored device tree
> > > -f free stored device tree
> > > - -d dump device tree from DTB or the parsed tree if no DTB is given
> > > - -n NODE specify root device NODE to dump for -d
> > >
> > > config CMD_TIME
> > > bool "time"
> > > diff --git a/commands/oftree.c b/commands/oftree.c
> > > index 16648d6..db31d59 100644
> > > --- a/commands/oftree.c
> > > +++ b/commands/oftree.c
> > > @@ -46,8 +46,6 @@ static int do_oftree(int argc, char *argv[])
> > > int size;
> > > int opt;
> > > char *file = NULL;
> > > - const char *node = "/";
> > > - int dump = 0;
> > > int probe = 0;
> > > int load = 0;
> > > int save = 0;
> > > @@ -55,14 +53,11 @@ static int do_oftree(int argc, char *argv[])
> > > int ret;
> > > struct device_node *n, *root;
> > >
> > > - while ((opt = getopt(argc, argv, "dpfn:ls")) > 0) {
> > > + while ((opt = getopt(argc, argv, "pfl:s:")) > 0) {
> >
> > Are you sure this optstring conversion is correct? Before there was
> > no optargs for -l and -s.
>
> Saw this right now in patch 6/6, sorry.
This hunk should be in 6/6. Will fix.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/6] of: Drop devicetree merge support
2014-05-19 20:59 ` [PATCH 5/6] of: Drop devicetree merge support Sascha Hauer
@ 2014-05-20 15:08 ` Sebastian Hesselbarth
2014-05-21 6:13 ` Sascha Hauer
2014-05-21 6:35 ` Esben Haabendal
2014-05-21 13:24 ` Holger Schurig
1 sibling, 2 replies; 17+ messages in thread
From: Sebastian Hesselbarth @ 2014-05-20 15:08 UTC (permalink / raw)
To: Sascha Hauer, barebox
On 05/19/2014 10:59 PM, Sascha Hauer wrote:
> I assume I am the only person knowing that barebox is able to
> merge devicetrees. This feature seems broken for a while now since
> trying to merge devicetress results in:
>
> unflatten: too many end nodes
Uhm, I know about it because I see it every time I load an updated
dtb on my hacky Chromecast barebox. Loading the dtb a second time
again works then..
Anyway, I don't want to merge any trees but overwrite the existing,
so I am fine with the removal ;)
Sebastian
> Remove this feature to save the complexity.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> arch/arm/boards/highbank/init.c | 2 +-
> arch/arm/cpu/dtb.c | 2 +-
> arch/arm/lib/bootm.c | 2 +-
> arch/mips/boot/dtb.c | 2 +-
> commands/of_dump.c | 2 +-
> commands/oftree.c | 9 +++------
> common/blspec.c | 2 +-
> common/bootm.c | 2 +-
> drivers/of/fdt.c | 44 +++++++++++------------------------------
> include/of.h | 2 +-
> 10 files changed, 23 insertions(+), 46 deletions(-)
>
> diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
> index d5d341a..7b4f963 100644
> --- a/arch/arm/boards/highbank/init.c
> +++ b/arch/arm/boards/highbank/init.c
> @@ -76,7 +76,7 @@ static int highbank_mem_init(void)
> /* load by the firmware at 0x1000 */
> fdt = IOMEM(FIRMWARE_DTB_BASE);
>
> - root = of_unflatten_dtb(NULL, fdt);
> + root = of_unflatten_dtb(fdt);
> if (!root) {
> pr_warn("no dtb found at 0x1000 use default configuration\n");
> fdt = NULL;
> diff --git a/arch/arm/cpu/dtb.c b/arch/arm/cpu/dtb.c
> index a5881dd..abc3ccb 100644
> --- a/arch/arm/cpu/dtb.c
> +++ b/arch/arm/cpu/dtb.c
> @@ -47,7 +47,7 @@ static int of_arm_init(void)
> return 0;
> }
>
> - root = of_unflatten_dtb(NULL, fdt);
> + root = of_unflatten_dtb(fdt);
> if (root) {
> of_set_root_node(root);
> if (IS_ENABLED(CONFIG_OFDEVICE))
> diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
> index 8035468..1d69052 100644
> --- a/arch/arm/lib/bootm.c
> +++ b/arch/arm/lib/bootm.c
> @@ -215,7 +215,7 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
> }
>
> if (IS_BUILTIN(CONFIG_OFTREE)) {
> - data->of_root_node = of_unflatten_dtb(NULL, oftree);
> + data->of_root_node = of_unflatten_dtb(oftree);
> if (!data->of_root_node) {
> pr_err("unable to unflatten devicetree\n");
> ret = -EINVAL;
> diff --git a/arch/mips/boot/dtb.c b/arch/mips/boot/dtb.c
> index c1962bf..23d8979 100644
> --- a/arch/mips/boot/dtb.c
> +++ b/arch/mips/boot/dtb.c
> @@ -48,7 +48,7 @@ static int of_mips_init(void)
> if (root)
> return 0;
>
> - root = of_unflatten_dtb(NULL, __dtb_start);
> + root = of_unflatten_dtb(__dtb_start);
> if (root) {
> pr_debug("using internal DTB\n");
> of_set_root_node(root);
> diff --git a/commands/of_dump.c b/commands/of_dump.c
> index 0ed47bb..1aefcc7 100644
> --- a/commands/of_dump.c
> +++ b/commands/of_dump.c
> @@ -63,7 +63,7 @@ static int do_of_dump(int argc, char *argv[])
> return -errno;
> }
>
> - root = of_unflatten_dtb(NULL, fdt);
> + root = of_unflatten_dtb(fdt);
>
> free(fdt);
>
> diff --git a/commands/oftree.c b/commands/oftree.c
> index db31d59..2c45b93 100644
> --- a/commands/oftree.c
> +++ b/commands/oftree.c
> @@ -51,7 +51,7 @@ static int do_oftree(int argc, char *argv[])
> int save = 0;
> int free_of = 0;
> int ret;
> - struct device_node *n, *root;
> + struct device_node *root;
>
> while ((opt = getopt(argc, argv, "pfl:s:")) > 0) {
> switch (opt) {
> @@ -130,16 +130,13 @@ static int do_oftree(int argc, char *argv[])
> goto out;
> }
>
> - n = of_get_root_node();
> -
> - root = of_unflatten_dtb(n, fdt);
> + root = of_unflatten_dtb(fdt);
> if (IS_ERR(root))
> ret = PTR_ERR(root);
> else
> ret = 0;
>
> - if (!n)
> - ret = of_set_root_node(root);
> + ret = of_set_root_node(root);
>
> if (ret) {
> printf("parse oftree: %s\n", strerror(-ret));
> diff --git a/common/blspec.c b/common/blspec.c
> index f165b77..9314eea 100644
> --- a/common/blspec.c
> +++ b/common/blspec.c
> @@ -281,7 +281,7 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
> goto out;
> }
>
> - root = of_unflatten_dtb(NULL, fdt);
> + root = of_unflatten_dtb(fdt);
> if (IS_ERR(root)) {
> ret = PTR_ERR(root);
> goto out;
> diff --git a/common/bootm.c b/common/bootm.c
> index 12d3ee0..b250bd1 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -297,7 +297,7 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
> return -EINVAL;
> }
>
> - data->of_root_node = of_unflatten_dtb(NULL, fdt);
> + data->of_root_node = of_unflatten_dtb(fdt);
> if (!data->of_root_node) {
> pr_err("unable to unflatten devicetree\n");
> free(fdt);
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 3dc5d47..8e4c775 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -54,20 +54,20 @@ static inline char *dt_string(struct fdt_header *f, char *strstart, uint32_t ofs
> * Parse a flat device tree binary blob and return a pointer to the
> * unflattened tree.
> */
> -struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
> +struct device_node *of_unflatten_dtb(void *infdt)
> {
> const void *nodep; /* property node pointer */
> uint32_t tag; /* tag */
> int len; /* length of the property */
> const struct fdt_property *fdt_prop;
> const char *pathp, *name;
> - struct device_node *node = NULL;
> + struct device_node *root, *node = NULL;
> struct property *p;
> uint32_t dt_struct;
> struct fdt_node_header *fnh;
> void *dt_strings;
> struct fdt_header f;
> - int ret, merge = 0;
> + int ret;
> unsigned int maxlen;
> struct fdt_header *fdt = infdt;
>
> @@ -100,14 +100,9 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
> dt_struct = f.off_dt_struct;
> dt_strings = (void *)fdt + f.off_dt_strings;
>
> - if (root) {
> - pr_debug("unflatten: merging into existing tree\n");
> - merge = 1;
> - } else {
> - root = of_new_node(NULL, NULL);
> - if (!root)
> - return ERR_PTR(-ENOMEM);
> - }
> + root = of_new_node(NULL, NULL);
> + if (!root)
> + return ERR_PTR(-ENOMEM);
>
> while (1) {
> tag = be32_to_cpu(*(uint32_t *)(infdt + dt_struct));
> @@ -132,15 +127,10 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
> goto err;
> }
>
> - if (!node) {
> + if (!node)
> node = root;
> - } else {
> - if (merge)
> - node = of_get_child_by_name(node,
> - pathp);
> - if (!merge || !node)
> - node = of_new_node(node, pathp);
> - }
> + else
> + node = of_new_node(node, pathp);
>
> break;
>
> @@ -179,19 +169,9 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
> goto err;
> }
>
> - p = NULL;
> - if (merge)
> - p = of_find_property(node, name, NULL);
> - if (merge && p) {
> - free(p->value);
> - p->value = xzalloc(len);
> - p->length = len;
> - memcpy(p->value, nodep, len);
> - } else {
> - p = of_new_property(node, name, nodep, len);
> - if (!strcmp(name, "phandle") && len == 4)
> - node->phandle = be32_to_cpup(p->value);
> - }
> + p = of_new_property(node, name, nodep, len);
> + if (!strcmp(name, "phandle") && len == 4)
> + node->phandle = be32_to_cpup(p->value);
>
> break;
>
> diff --git a/include/of.h b/include/of.h
> index 3183428..e6993fd 100644
> --- a/include/of.h
> +++ b/include/of.h
> @@ -98,7 +98,7 @@ void of_print_cmdline(struct device_node *root);
> void of_print_nodes(struct device_node *node, int indent);
> int of_probe(void);
> int of_parse_dtb(struct fdt_header *fdt);
> -struct device_node *of_unflatten_dtb(struct device_node *root, void *fdt);
> +struct device_node *of_unflatten_dtb(void *fdt);
>
> struct cdev;
>
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/6] of: Drop devicetree merge support
2014-05-20 15:08 ` Sebastian Hesselbarth
@ 2014-05-21 6:13 ` Sascha Hauer
2014-05-21 6:35 ` Esben Haabendal
1 sibling, 0 replies; 17+ messages in thread
From: Sascha Hauer @ 2014-05-21 6:13 UTC (permalink / raw)
To: Sebastian Hesselbarth; +Cc: barebox
On Tue, May 20, 2014 at 05:08:15PM +0200, Sebastian Hesselbarth wrote:
> On 05/19/2014 10:59 PM, Sascha Hauer wrote:
> > I assume I am the only person knowing that barebox is able to
> > merge devicetrees. This feature seems broken for a while now since
> > trying to merge devicetress results in:
> >
> > unflatten: too many end nodes
>
> Uhm, I know about it because I see it every time I load an updated
> dtb on my hacky Chromecast barebox. Loading the dtb a second time
> again works then..
>
> Anyway, I don't want to merge any trees but overwrite the existing,
> so I am fine with the removal ;)
Merging devicetrees may actually come back with the devicetree overlay
feature Pantelis Antoniou is working on. I'm waiting for this to be
merged in upstream dtc before further looking at it.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/6] of: Drop devicetree merge support
2014-05-20 15:08 ` Sebastian Hesselbarth
2014-05-21 6:13 ` Sascha Hauer
@ 2014-05-21 6:35 ` Esben Haabendal
2014-05-21 12:39 ` Sascha Hauer
1 sibling, 1 reply; 17+ messages in thread
From: Esben Haabendal @ 2014-05-21 6:35 UTC (permalink / raw)
To: Sebastian Hesselbarth; +Cc: barebox
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> writes:
> On 05/19/2014 10:59 PM, Sascha Hauer wrote:
>> I assume I am the only person knowing that barebox is able to
>> merge devicetrees. This feature seems broken for a while now since
>> trying to merge devicetress results in:
>>
>> unflatten: too many end nodes
>
> Uhm, I know about it because I see it every time I load an updated
> dtb on my hacky Chromecast barebox. Loading the dtb a second time
> again works then..
>
> Anyway, I don't want to merge any trees but overwrite the existing,
> so I am fine with the removal ;)
I actually wanted to merge dtb trees for a project at hand, but ended up
doing the merge before hand.
So no, you were not the only one knowing about it ;)
/Esben
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/6] of: Drop devicetree merge support
2014-05-21 6:35 ` Esben Haabendal
@ 2014-05-21 12:39 ` Sascha Hauer
0 siblings, 0 replies; 17+ messages in thread
From: Sascha Hauer @ 2014-05-21 12:39 UTC (permalink / raw)
To: Esben Haabendal; +Cc: barebox
On Wed, May 21, 2014 at 08:35:11AM +0200, Esben Haabendal wrote:
> Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> writes:
>
> > On 05/19/2014 10:59 PM, Sascha Hauer wrote:
> >> I assume I am the only person knowing that barebox is able to
> >> merge devicetrees. This feature seems broken for a while now since
> >> trying to merge devicetress results in:
> >>
> >> unflatten: too many end nodes
> >
> > Uhm, I know about it because I see it every time I load an updated
> > dtb on my hacky Chromecast barebox. Loading the dtb a second time
> > again works then..
> >
> > Anyway, I don't want to merge any trees but overwrite the existing,
> > so I am fine with the removal ;)
>
> I actually wanted to merge dtb trees for a project at hand, but ended up
> doing the merge before hand.
>
> So no, you were not the only one knowing about it ;)
You see me surprised.
Anyway, as you decided to not use it we still do not have a user.
I think using the "official" overlay support for this is the cleaner
way to implement this feature. Another important thing is that a tree
should be explicitly merged with a separate command or option. Just
turning -l (load) option to a merge option when a devicetree is already
present was confusing.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/6] commands: add of_dump command
2014-05-19 20:59 ` [PATCH 3/6] commands: add of_dump command Sascha Hauer
@ 2014-05-21 13:17 ` Holger Schurig
2014-05-22 6:10 ` Sascha Hauer
0 siblings, 1 reply; 17+ messages in thread
From: Holger Schurig @ 2014-05-21 13:17 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
> + -f <dtb> work on <dtb> instead of internal devicetree
> +BAREBOX_CMD_HELP_OPT ("-f <dtb>", "work on <dtb> instead of internal devicetree\n")
In my command-rework patches I have used "-f FOO" instead of "-f
<foo>". Two reasons:
1. saves 2 bytes
2. less occurences of column align fixup with extra \t needed
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/6] of: Drop devicetree merge support
2014-05-19 20:59 ` [PATCH 5/6] of: Drop devicetree merge support Sascha Hauer
2014-05-20 15:08 ` Sebastian Hesselbarth
@ 2014-05-21 13:24 ` Holger Schurig
1 sibling, 0 replies; 17+ messages in thread
From: Holger Schurig @ 2014-05-21 13:24 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
> I assume I am the only person knowing that barebox is able to
> merge devicetrees.
Hihi, any software feature that isn't documented is (almost) the same
as never been written.
I personally don't need merging, but maybe it can be handy to support
those boards that have plug-on boards, a la "Shields".
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/6] commands: add of_dump command
2014-05-21 13:17 ` Holger Schurig
@ 2014-05-22 6:10 ` Sascha Hauer
0 siblings, 0 replies; 17+ messages in thread
From: Sascha Hauer @ 2014-05-22 6:10 UTC (permalink / raw)
To: Holger Schurig; +Cc: barebox
On Wed, May 21, 2014 at 03:17:20PM +0200, Holger Schurig wrote:
> > + -f <dtb> work on <dtb> instead of internal devicetree
> > +BAREBOX_CMD_HELP_OPT ("-f <dtb>", "work on <dtb> instead of internal devicetree\n")
>
> In my command-rework patches I have used "-f FOO" instead of "-f
> <foo>". Two reasons:
>
> 1. saves 2 bytes
> 2. less occurences of column align fixup with extra \t needed
Ok, I removed the <>.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2014-05-22 6:10 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-19 20:59 [PATCH] devicetree command changes Sascha Hauer
2014-05-19 20:59 ` [PATCH 1/6] complete: Fix completion after options Sascha Hauer
2014-05-19 20:59 ` [PATCH 2/6] complete: Add devicetree completion Sascha Hauer
2014-05-19 20:59 ` [PATCH 3/6] commands: add of_dump command Sascha Hauer
2014-05-21 13:17 ` Holger Schurig
2014-05-22 6:10 ` Sascha Hauer
2014-05-19 20:59 ` [PATCH 4/6] oftree: remove dump support Sascha Hauer
2014-05-20 8:01 ` Alexander Aring
2014-05-20 8:03 ` Alexander Aring
2014-05-20 9:08 ` Sascha Hauer
2014-05-19 20:59 ` [PATCH 5/6] of: Drop devicetree merge support Sascha Hauer
2014-05-20 15:08 ` Sebastian Hesselbarth
2014-05-21 6:13 ` Sascha Hauer
2014-05-21 6:35 ` Esben Haabendal
2014-05-21 12:39 ` Sascha Hauer
2014-05-21 13:24 ` Holger Schurig
2014-05-19 20:59 ` [PATCH 6/6] oftree command: make devicetree file optargs to -l/-s Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox