From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] of_dump: Add option to print node names only
Date: Mon, 26 Oct 2015 14:10:24 +0100 [thread overview]
Message-ID: <1445865024-2846-1-git-send-email-s.hauer@pengutronix.de> (raw)
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>
---
commands/of_dump.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/commands/of_dump.c b/commands/of_dump.c
index 513a4b8..b15f54a 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)
--
2.6.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2015-10-26 13:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445865024-2846-1-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox