diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-12-09 11:57:27 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-12-13 23:16:01 +0100 |
commit | 1973008ce2ca5038847a6bd87c8a23db4529deeb (patch) | |
tree | e9d116bc2e137810455030f99cf7dcd49c5e15d3 | |
parent | 9be33a90a5bca28e586dcb8ae73cf99841ed2085 (diff) | |
download | barebox-1973008ce2ca5038847a6bd87c8a23db4529deeb.tar.gz barebox-1973008ce2ca5038847a6bd87c8a23db4529deeb.tar.xz |
of: make of_dump abortable by ctrlc()
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>
Link: https://lore.barebox.org/20211209105727.3517863-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | commands/of_dump.c | 5 | ||||
-rw-r--r-- | 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 5223ba63ad..6f36b31514 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 065265ec97..de75796182 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) |