From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] clk_dump command: Allow printing a single clock
Date: Wed, 23 Sep 2020 10:54:26 +0200 [thread overview]
Message-ID: <20200923085426.8172-1-s.hauer@pengutronix.de> (raw)
So far the clk_dump command can only print all clocks. With this patch
we can limit the output to ancestors and children of a given clock. This
makes it easier to find the desired information in big clock trees.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/clk.c | 15 ++++++++++++--
drivers/clk/clk.c | 50 ++++++++++++++++++++++++++++++++++++++++-----
include/linux/clk.h | 1 +
3 files changed, 59 insertions(+), 7 deletions(-)
diff --git a/commands/clk.c b/commands/clk.c
index 47159dddd2..649a0a7cb2 100644
--- a/commands/clk.c
+++ b/commands/clk.c
@@ -139,6 +139,7 @@ BAREBOX_CMD_END
static int do_clk_dump(int argc, char *argv[])
{
int opt, verbose = 0;
+ struct clk *clk;
while ((opt = getopt(argc, argv, "v")) > 0) {
switch(opt) {
@@ -151,7 +152,16 @@ static int do_clk_dump(int argc, char *argv[])
}
}
- clk_dump(verbose);
+ if (optind == argc) {
+ clk_dump(verbose);
+ return COMMAND_SUCCESS;
+ }
+
+ clk = clk_lookup(argv[optind]);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ clk_dump_one(clk, verbose);
return COMMAND_SUCCESS;
}
@@ -164,9 +174,10 @@ BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(clk_dump)
.cmd = do_clk_dump,
BAREBOX_CMD_DESC("show information about registered clocks")
- BAREBOX_CMD_OPTS("[-v]")
+ BAREBOX_CMD_OPTS("[-v] [clkname]")
BAREBOX_CMD_GROUP(CMD_GRP_INFO)
BAREBOX_CMD_HELP(cmd_clk_dump_help)
+ BAREBOX_CMD_COMPLETE(clk_name_complete)
BAREBOX_CMD_END
static int do_clk_set_parent(int argc, char *argv[])
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index f2e459a760..b04d44593b 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -678,7 +678,6 @@ static const char *clk_hw_stat(struct clk *clk)
static void dump_one(struct clk *clk, int verbose, int indent)
{
- struct clk *c;
int enabled = clk_is_enabled(clk);
const char *hwstat, *stat;
@@ -705,13 +704,19 @@ static void dump_one(struct clk *clk, int verbose, int indent)
printf("\n");
}
}
+}
+
+static void dump_subtree(struct clk *clk, int verbose, int indent)
+{
+ struct clk *c;
+
+ dump_one(clk, verbose, indent);
list_for_each_entry(c, &clks, list) {
struct clk *parent = clk_get_parent(c);
- if (parent == clk) {
- dump_one(c, verbose, indent + 1);
- }
+ if (parent == clk)
+ dump_subtree(c, verbose, indent + 1);
}
}
@@ -723,7 +728,42 @@ void clk_dump(int verbose)
struct clk *parent = clk_get_parent(c);
if (IS_ERR_OR_NULL(parent))
- dump_one(c, verbose, 0);
+ dump_subtree(c, verbose, 0);
+ }
+}
+
+static int clk_print_parent(struct clk *clk, int verbose)
+{
+ struct clk *c;
+ int indent;
+
+ c = clk_get_parent(clk);
+ if (IS_ERR_OR_NULL(c))
+ return 0;
+
+ indent = clk_print_parent(c, verbose);
+
+ dump_one(c, verbose, indent);
+
+ return indent + 1;
+}
+
+void clk_dump_one(struct clk *clk, int verbose)
+{
+ int indent;
+ struct clk *c;
+
+ indent = clk_print_parent(clk, verbose);
+
+ printf("\033[1m");
+ dump_one(clk, verbose, indent);
+ printf("\033[0m");
+
+ list_for_each_entry(c, &clks, list) {
+ struct clk *parent = clk_get_parent(c);
+
+ if (parent == clk)
+ dump_subtree(c, verbose, indent + 1);
}
}
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 868bf3e4ed..3d66343e8d 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -456,6 +456,7 @@ int clk_register(struct clk *clk);
struct clk *clk_lookup(const char *name);
void clk_dump(int verbose);
+void clk_dump_one(struct clk *clk, int verbose);
struct clk *clk_register_composite(const char *name,
const char * const *parent_names, int num_parents,
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2020-09-23 8:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200923085426.8172-1-s.hauer@pengutronix.de \
--to=s.hauer@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