[PATCH] of: make of_dump abortable by ctrlc()

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

 



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@xxxxxxxxxxxxxx>
---
 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@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