[PATCH] commands: of_dump: implement -p for printing properties only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some boards rewrite root node properties like compatible and
serial-number. Checking them can be annoying, because the properties
have usually long scrolled by, by the time the device tree was
completely dumped. Add a -p option to print only properties.

-p -n (print only node names AND only properties) is interpreted
to cancel each other out, so the whole device tree is dumped normally.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 commands/of_dump.c | 14 ++++++++++----
 drivers/of/base.c  |  8 ++++++++
 include/of.h       |  1 +
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/commands/of_dump.c b/commands/of_dump.c
index 6792af3afc31..2089c07ef79b 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -36,9 +36,9 @@ static int do_of_dump(int argc, char *argv[])
 	char *dtbfile = NULL;
 	size_t size;
 	const char *nodename;
-	int names_only = 0;
+	int names_only = 0, properties_only = 0;
 
-	while ((opt = getopt(argc, argv, "Ff:n")) > 0) {
+	while ((opt = getopt(argc, argv, "Ff:np")) > 0) {
 		switch (opt) {
 		case 'f':
 			dtbfile = optarg;
@@ -49,6 +49,9 @@ static int do_of_dump(int argc, char *argv[])
 		case 'n':
 			names_only = 1;
 			break;
+		case 'p':
+			properties_only = 1;
+			break;
 		default:
 			return COMMAND_ERROR_USAGE;
 		}
@@ -111,8 +114,10 @@ static int do_of_dump(int argc, char *argv[])
 		goto out;
 	}
 
-	if (names_only)
+	if (names_only && !properties_only)
 		of_print_nodenames(node);
+	else if (properties_only && !names_only)
+		of_print_properties(node);
 	else
 		of_print_nodes(node, 0);
 
@@ -128,12 +133,13 @@ BAREBOX_CMD_HELP_TEXT("Options:")
 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_END
 
 BAREBOX_CMD_START(of_dump)
 	.cmd		= do_of_dump,
 	BAREBOX_CMD_DESC("dump devicetree nodes")
-	BAREBOX_CMD_OPTS("[-fFn] [NODE]")
+	BAREBOX_CMD_OPTS("[-fFnp] [NODE]")
 	BAREBOX_CMD_GROUP(CMD_GRP_MISC)
 	BAREBOX_CMD_COMPLETE(devicetree_file_complete)
 	BAREBOX_CMD_HELP(cmd_of_dump_help)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 6fe02649ee53..e103eed90af1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2002,6 +2002,14 @@ static void __of_print_property(struct property *p, int indent)
 	printf(";\n");
 }
 
+void of_print_properties(struct device_node *node)
+{
+	struct property *prop;
+
+	list_for_each_entry(prop, &node->properties, list)
+		__of_print_property(prop, 0);
+}
+
 static int __of_print_parents(struct device_node *node)
 {
 	int indent, i;
diff --git a/include/of.h b/include/of.h
index 645f429bdeed..55e6bff8689e 100644
--- a/include/of.h
+++ b/include/of.h
@@ -105,6 +105,7 @@ void of_print_property(const void *data, int len);
 void of_print_cmdline(struct device_node *root);
 
 void of_print_nodes(struct device_node *node, int indent);
+void of_print_properties(struct device_node *node);
 void of_diff(struct device_node *a, struct device_node *b, int indent);
 int of_probe(void);
 int of_parse_dtb(struct fdt_header *fdt);
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux