mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] of: make of_dump abortable by ctrlc()
@ 2021-12-09 10:57 Ahmad Fatoum
  2021-12-13 22:16 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2021-12-09 10:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Some device trees can be quite long, e.g. because they contain all
possible pinmux entries. Writing that out over serial can take quite a
while. Check for ctrlc() between nodes to make these less annoying.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 commands/of_dump.c |  5 ++++-
 drivers/of/base.c  | 13 ++++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/commands/of_dump.c b/commands/of_dump.c
index 5223ba63ad23..6f36b3151458 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -23,8 +23,11 @@ static void of_print_nodenames(struct device_node *node)
 
 	printf("%s\n", node->full_name);
 
-	list_for_each_entry(n, &node->children, parent_list)
+	list_for_each_entry(n, &node->children, parent_list) {
+		if (ctrlc())
+			return;
 		of_print_nodenames(n);
+	}
 }
 
 static int do_of_dump(int argc, char *argv[])
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 321022f2b391..664a3a411eaf 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1968,13 +1968,14 @@ int of_property_read_string_helper(const struct device_node *np,
 	return i <= 0 ? -ENODATA : i;
 }
 
-static void __of_print_nodes(struct device_node *node, int indent, const char *prefix)
+static int __of_print_nodes(struct device_node *node, int indent, const char *prefix)
 {
 	struct device_node *n;
 	struct property *p;
+	int ret;
 
 	if (!node)
-		return;
+		return 0;
 
 	if (!prefix)
 		prefix = "";
@@ -1990,11 +1991,17 @@ static void __of_print_nodes(struct device_node *node, int indent, const char *p
 		printf(";\n");
 	}
 
+	if (ctrlc())
+		return -EINTR;
+
 	list_for_each_entry(n, &node->children, parent_list) {
-		__of_print_nodes(n, indent + 1, prefix);
+		ret = __of_print_nodes(n, indent + 1, prefix);
+		if (ret)
+			return ret;
 	}
 
 	printf("%s%*s};\n", prefix, indent * 8, "");
+	return 0;
 }
 
 void of_print_nodes(struct device_node *node, int indent)
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-13 22:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 10:57 [PATCH] of: make of_dump abortable by ctrlc() Ahmad Fatoum
2021-12-13 22:16 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox