diff mbox series

[RFC,3/4] clk: Add consumers count information to debugfs

Message ID 20220707100309.1357663-3-abel.vesa@linaro.org (mailing list archive)
State Not Applicable
Headers show
Series [RFC,1/4] clk: Use clk_core_unlink_consumer on __clk_put | expand

Commit Message

Abel Vesa July 7, 2022, 10:03 a.m. UTC
Lets add consumers count information to debugfs. It could be useful for
identifying which clocks do not have a consumer but are enabled at boot
and should be disabled since they are unused. Also you could tell which
clocks are marked as critical since they do not have consumers, but
their enable_count is non-zero.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
 drivers/clk/clk.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 9b54afd2fee8..e412e83a6e28 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2955,9 +2955,9 @@  static void clk_summary_show_one(struct seq_file *s, struct clk_core *c,
 {
 	int phase;
 
-	seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu ",
+	seq_printf(s, "%*s%-*s %7d %7d %8d %8d %11lu %10lu ",
 		   level * 3 + 1, "",
-		   30 - level * 3, c->name,
+		   30 - level * 3, c->name, c->consumers_count,
 		   c->enable_count, c->prepare_count, c->protect_count,
 		   clk_core_get_rate_recalc(c),
 		   clk_core_get_accuracy_recalc(c));
@@ -2996,9 +2996,9 @@  static int clk_summary_show(struct seq_file *s, void *data)
 	struct clk_core *c;
 	struct hlist_head **lists = (struct hlist_head **)s->private;
 
-	seq_puts(s, "                                 enable  prepare  protect                                duty  hardware\n");
-	seq_puts(s, "   clock                          count    count    count        rate   accuracy phase  cycle    enable\n");
-	seq_puts(s, "-------------------------------------------------------------------------------------------------------\n");
+	seq_puts(s, "                                 counsumers  enable  prepare  protect                                duty  hardware\n");
+	seq_puts(s, "   clock                              count   count    count    count        rate   accuracy phase  cycle    enable\n");
+	seq_puts(s, "-------------------------------------------------------------------------------------------------------------------\n");
 
 	clk_prepare_lock();
 
@@ -3021,6 +3021,7 @@  static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
 
 	/* This should be JSON format, i.e. elements separated with a comma */
 	seq_printf(s, "\"%s\": { ", c->name);
+	seq_printf(s, "\"consumers_count\": %d,", c->consumers_count);
 	seq_printf(s, "\"enable_count\": %d,", c->enable_count);
 	seq_printf(s, "\"prepare_count\": %d,", c->prepare_count);
 	seq_printf(s, "\"protect_count\": %d,", c->protect_count);
@@ -3330,6 +3331,7 @@  static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 	debugfs_create_u32("clk_phase", 0444, root, &core->phase);
 	debugfs_create_file("clk_flags", 0444, root, core, &clk_flags_fops);
 	debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count);
+	debugfs_create_u32("clk_consumers_count", 0444, root, &core->consumers_count);
 	debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
 	debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
 	debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);