summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-10-21 13:20:57 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-10-26 14:08:19 +0100
commit31fd4cceb63aab1ec27a8d5e1a70a54d7cfdc914 (patch)
tree531a147d899803124cb1fd05ba9b40e08c4c9f98 /commands
parenta1aa681089ad59ebfb702fda57349f0014f5d1d9 (diff)
downloadbarebox-31fd4cceb63aab1ec27a8d5e1a70a54d7cfdc914.tar.gz
barebox-31fd4cceb63aab1ec27a8d5e1a70a54d7cfdc914.tar.xz
of_dump: Add option to print node names only
Devicetrees tend to become very long and it is hard to find the interesting nodes in a full tree output. This patch adds the -n option to the of_node command. With this option only the names of the nodes are printed, but not the properties. The resulting output is much shorter and the node one is interested in can be copy/pasted to a second call to of_node. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/of_dump.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/commands/of_dump.c b/commands/of_dump.c
index 513a4b88a0..b15f54ae04 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -31,6 +31,16 @@
#include <getopt.h>
#include <linux/err.h>
+static void of_print_nodenames(struct device_node *node)
+{
+ struct device_node *n;
+
+ printf("%s\n", node->full_name);
+
+ list_for_each_entry(n, &node->children, parent_list)
+ of_print_nodenames(n);
+}
+
static int do_of_dump(int argc, char *argv[])
{
int opt;
@@ -40,8 +50,9 @@ static int do_of_dump(int argc, char *argv[])
char *dtbfile = NULL;
size_t size;
const char *nodename;
+ int names_only = 0;
- while ((opt = getopt(argc, argv, "Ff:")) > 0) {
+ while ((opt = getopt(argc, argv, "Ff:n")) > 0) {
switch (opt) {
case 'f':
dtbfile = optarg;
@@ -49,6 +60,9 @@ static int do_of_dump(int argc, char *argv[])
case 'F':
fix = 1;
break;
+ case 'n':
+ names_only = 1;
+ break;
default:
return COMMAND_ERROR_USAGE;
}
@@ -111,7 +125,10 @@ static int do_of_dump(int argc, char *argv[])
goto out;
}
- of_print_nodes(node, 0);
+ if (names_only)
+ of_print_nodenames(node);
+ else
+ of_print_nodes(node, 0);
out:
if (of_free)