mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] clk: add flags parameter to clk_dump(_one)
Date: Fri, 19 Apr 2024 08:07:58 +0200	[thread overview]
Message-ID: <20240419060759.2590652-1-a.fatoum@pengutronix.de> (raw)

We currently customize dumping by means of a single verbose argument.
Follow-up commit will want to customize the dumping further, so turn
the verbose parameter into a general flags parameter.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 commands/clk.c      |  8 ++++----
 drivers/clk/clk.c   | 28 ++++++++++++++--------------
 include/linux/clk.h |  5 +++--
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/commands/clk.c b/commands/clk.c
index 606519091e86..290acd842e78 100644
--- a/commands/clk.c
+++ b/commands/clk.c
@@ -163,13 +163,13 @@ BAREBOX_CMD_END
 
 static int do_clk_dump(int argc, char *argv[])
 {
-	int opt, verbose = 0;
+	int opt, flags = 0;
 	struct clk *clk;
 
 	while ((opt = getopt(argc, argv, "v")) > 0) {
 		switch(opt) {
 		case 'v':
-			verbose = 1;
+			flags |= CLK_DUMP_VERBOSE;
 			break;
 		default:
 			return -EINVAL;
@@ -178,7 +178,7 @@ static int do_clk_dump(int argc, char *argv[])
 	}
 
 	if (optind == argc) {
-		clk_dump(verbose);
+		clk_dump(flags);
 		return COMMAND_SUCCESS;
 	}
 
@@ -186,7 +186,7 @@ static int do_clk_dump(int argc, char *argv[])
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	clk_dump_one(clk, verbose);
+	clk_dump_one(clk, flags);
 
 	return COMMAND_SUCCESS;
 }
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 03533b61df0a..f9abd3147766 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1033,7 +1033,7 @@ static const char *clk_parent_name_by_index(struct clk *clk, u8 idx)
 	return "unknown";
 }
 
-static void dump_one(struct clk *clk, int verbose, int indent)
+static void dump_one(struct clk *clk, int flags, int indent)
 {
 	int enabled = clk_is_enabled(clk);
 	const char *hwstat, *stat;
@@ -1051,7 +1051,7 @@ static void dump_one(struct clk *clk, int verbose, int indent)
 	       clk->enable_count,
 	       hwstat);
 
-	if (verbose) {
+	if (flags & CLK_DUMP_VERBOSE) {
 
 		if (clk->num_parents > 1) {
 			int i;
@@ -1063,21 +1063,21 @@ static void dump_one(struct clk *clk, int verbose, int indent)
 	}
 }
 
-static void dump_subtree(struct clk *clk, int verbose, int indent)
+static void dump_subtree(struct clk *clk, int flags, int indent)
 {
 	struct clk *c;
 
-	dump_one(clk, verbose, indent);
+	dump_one(clk, flags, indent);
 
 	list_for_each_entry(c, &clks, list) {
 		struct clk *parent = clk_get_parent(c);
 
 		if (parent == clk)
-			dump_subtree(c, verbose, indent + 1);
+			dump_subtree(c, flags, indent + 1);
 	}
 }
 
-void clk_dump(int verbose)
+void clk_dump(int flags)
 {
 	struct clk *c;
 
@@ -1085,11 +1085,11 @@ void clk_dump(int verbose)
 		struct clk *parent = clk_get_parent(c);
 
 		if (IS_ERR_OR_NULL(parent))
-			dump_subtree(c, verbose, 0);
+			dump_subtree(c, flags, 0);
 	}
 }
 
-static int clk_print_parent(struct clk *clk, int verbose)
+static int clk_print_parent(struct clk *clk, int flags)
 {
 	struct clk *c;
 	int indent;
@@ -1098,29 +1098,29 @@ static int clk_print_parent(struct clk *clk, int verbose)
 	if (IS_ERR_OR_NULL(c))
 		return 0;
 
-	indent = clk_print_parent(c, verbose);
+	indent = clk_print_parent(c, flags);
 
-	dump_one(c, verbose, indent);
+	dump_one(c, flags, indent);
 
 	return indent + 1;
 }
 
-void clk_dump_one(struct clk *clk, int verbose)
+void clk_dump_one(struct clk *clk, int flags)
 {
 	int indent;
 	struct clk *c;
 
-	indent = clk_print_parent(clk, verbose);
+	indent = clk_print_parent(clk, flags);
 
 	printf("\033[1m");
-	dump_one(clk, verbose, indent);
+	dump_one(clk, flags, 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);
+			dump_subtree(c, flags, indent + 1);
 	}
 }
 
diff --git a/include/linux/clk.h b/include/linux/clk.h
index e4efc2b77044..f2e3a443c20f 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -724,8 +724,9 @@ static inline int clk_hw_register(struct device *dev, struct clk_hw *hw)
 
 struct clk *clk_lookup(const char *name);
 
-void clk_dump(int verbose);
-void clk_dump_one(struct clk *clk, int verbose);
+#define CLK_DUMP_VERBOSE	(1 << 0)
+void clk_dump(int flags);
+void clk_dump_one(struct clk *clk, int flags);
 
 struct clk *clk_register_composite(const char *name,
 			const char * const *parent_names, int num_parents,
-- 
2.39.2




             reply	other threads:[~2024-04-19  6:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19  6:07 Ahmad Fatoum [this message]
2024-04-19  6:07 ` [PATCH 2/2] commands: clk_dump: add json output option Ahmad Fatoum
2024-04-22 11:24 ` [PATCH 1/2] clk: add flags parameter to clk_dump(_one) 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=20240419060759.2590652-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