summaryrefslogtreecommitdiffstats
path: root/commands/of_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'commands/of_dump.c')
-rw-r--r--commands/of_dump.c65
1 files changed, 21 insertions, 44 deletions
diff --git a/commands/of_dump.c b/commands/of_dump.c
index 6f36b31514..2508d4ce11 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -21,7 +21,7 @@ static void of_print_nodenames(struct device_node *node)
{
struct device_node *n;
- printf("%s\n", node->full_name);
+ printf("%pOF\n", node);
list_for_each_entry(n, &node->children, parent_list) {
if (ctrlc())
@@ -37,11 +37,11 @@ static int do_of_dump(int argc, char *argv[])
int fix = 0;
struct device_node *root = NULL, *node, *of_free = NULL;
char *dtbfile = NULL;
- size_t size;
const char *nodename;
+ unsigned maxpropsize = ~0;
int names_only = 0, properties_only = 0;
- while ((opt = getopt(argc, argv, "Ff:np")) > 0) {
+ while ((opt = getopt(argc, argv, "Ff:npP:")) > 0) {
switch (opt) {
case 'f':
dtbfile = optarg;
@@ -55,6 +55,11 @@ static int do_of_dump(int argc, char *argv[])
case 'p':
properties_only = 1;
break;
+ case 'P':
+ ret = kstrtouint(optarg, 0, &maxpropsize);
+ if (ret)
+ return ret;
+ break;
default:
return COMMAND_ERROR_USAGE;
}
@@ -66,49 +71,21 @@ static int do_of_dump(int argc, char *argv[])
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(fdt, size);
-
- free(fdt);
-
- if (IS_ERR(root)) {
- ret = PTR_ERR(root);
- goto out;
- }
+ root = of_read_file(dtbfile);
+ if (IS_ERR(root))
+ return PTR_ERR(root);
of_free = root;
} else {
root = of_get_root_node();
- if (fix) {
- /* create a copy of internal devicetree */
- void *fdt;
- fdt = of_flatten_dtb(root);
- root = of_unflatten_dtb(fdt, fdt_totalsize(fdt));
-
- free(fdt);
-
- if (IS_ERR(root)) {
- ret = PTR_ERR(root);
- goto out;
- }
-
- of_free = root;
- }
+ /* copy internal device tree to apply fixups onto it */
+ if (fix)
+ root = of_free = of_dup(root);
}
- if (fix) {
- ret = of_fix_tree(root);
- if (ret)
- goto out;
- }
+ if (fix)
+ of_fix_tree(root);
node = of_find_node_by_path_or_alias(root, nodename);
if (!node) {
@@ -120,13 +97,12 @@ static int do_of_dump(int argc, char *argv[])
if (names_only && !properties_only)
of_print_nodenames(node);
else if (properties_only && !names_only)
- of_print_properties(node);
+ of_print_properties(node, maxpropsize);
else
- of_print_nodes(node, 0);
+ of_print_nodes(node, 0, maxpropsize);
out:
- if (of_free)
- of_delete_node(of_free);
+ of_delete_node(of_free);
return ret;
}
@@ -137,12 +113,13 @@ BAREBOX_CMD_HELP_OPT ("-f dtb", "work on dtb instead of internal devicetree")
BAREBOX_CMD_HELP_OPT ("-F", "return fixed devicetree")
BAREBOX_CMD_HELP_OPT ("-n", "Print node names only, no properties")
BAREBOX_CMD_HELP_OPT ("-p", "Print properties only, no child nodes")
+BAREBOX_CMD_HELP_OPT ("-P len", "print only len property bytes")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(of_dump)
.cmd = do_of_dump,
BAREBOX_CMD_DESC("dump devicetree nodes")
- BAREBOX_CMD_OPTS("[-fFnp] [NODE]")
+ BAREBOX_CMD_OPTS("[-fFnpP] [NODE]")
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
BAREBOX_CMD_COMPLETE(devicetree_file_complete)
BAREBOX_CMD_HELP(cmd_of_dump_help)