From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] of: make of_dump abortable by ctrlc()
Date: Thu, 9 Dec 2021 11:57:27 +0100 [thread overview]
Message-ID: <20211209105727.3517863-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2021-12-09 10:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 10:57 Ahmad Fatoum [this message]
2021-12-13 22:16 ` Sascha Hauer
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=20211209105727.3517863-1-a.fatoum@pengutronix.de \
--to=a.fatoum@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