linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	patches@lists.linux.dev
Subject: [PATCH 1/4] clk: Prepare clk_debug_create_one() to be split off
Date: Tue,  7 Jan 2025 16:58:46 -0800	[thread overview]
Message-ID: <20250108005854.2973184-2-sboyd@kernel.org> (raw)
In-Reply-To: <20250108005854.2973184-1-sboyd@kernel.org>

In a later patch we're going to move clk_debug_create_one() to a
loadable kernel module. Prepare for that step by returning the dentry
created in there from the function and wrap that all up in a new
function, clk_core_debug_create_one(), that we can call in both places
the dentry is created. Similarly, don't pass the 'pdentry' argument to
clk_debug_create_one() because it's always the global 'rootdir', so just
use that where it is used instead of passing it. We can remove the NULL
checks too because we know the pointers are always valid.

Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
 drivers/clk/clk.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index bdc6e5b90da5..1a94a27194c9 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3705,14 +3705,11 @@ static int clk_max_rate_show(struct seq_file *s, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(clk_max_rate);
 
-static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
+static struct dentry *clk_debug_create_one(struct clk_core *core)
 {
 	struct dentry *root;
 
-	if (!core || !pdentry)
-		return;
-
-	root = debugfs_create_dir(core->name, pdentry);
+	root = debugfs_create_dir(core->name, rootdir);
 	core->dentry = root;
 
 	debugfs_create_file("clk_rate", clk_rate_mode, root, core,
@@ -3746,8 +3743,19 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 		debugfs_create_file("clk_possible_parents", 0444, root, core,
 				    &possible_parents_fops);
 
+	return root;
+}
+
+static void clk_core_debug_create_one(struct clk_core *core)
+{
+	struct clk_hw *hw = core->hw;
+
+	if (!inited)
+		return;
+
+	core->dentry = clk_debug_create_one(core);
 	if (core->ops->debug_init)
-		core->ops->debug_init(core->hw, core->dentry);
+		core->ops->debug_init(hw, core->dentry);
 }
 
 /**
@@ -3762,8 +3770,7 @@ static void clk_debug_register(struct clk_core *core)
 {
 	mutex_lock(&clk_debug_lock);
 	hlist_add_head(&core->debug_node, &clk_debug_list);
-	if (inited)
-		clk_debug_create_one(core, rootdir);
+	clk_core_debug_create_one(core);
 	mutex_unlock(&clk_debug_lock);
 }
 
@@ -3827,10 +3834,9 @@ static int __init clk_debug_init(void)
 			    &clk_dump_fops);
 
 	mutex_lock(&clk_debug_lock);
-	hlist_for_each_entry(core, &clk_debug_list, debug_node)
-		clk_debug_create_one(core, rootdir);
-
 	inited = 1;
+	hlist_for_each_entry(core, &clk_debug_list, debug_node)
+		clk_core_debug_create_one(core);
 	mutex_unlock(&clk_debug_lock);
 
 	return 0;
-- 
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git


  reply	other threads:[~2025-01-08  0:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08  0:58 [PATCH 0/4] clk: Move debugfs to a loadable kernel module Stephen Boyd
2025-01-08  0:58 ` Stephen Boyd [this message]
2025-01-08  0:58 ` [PATCH 2/4] clk: Use struct clk_hw instead of struct clk_core for debugfs Stephen Boyd
2025-01-08  0:58 ` [PATCH 3/4] clk: Iterate instead of recurse for debugfs printing Stephen Boyd
2025-01-08  0:58 ` [PATCH 4/4] clk: Make debugfs code into a loadable kernel module Stephen Boyd
2025-01-10  6:45   ` kernel test robot
2025-01-11 11:51   ` kernel test robot
2025-01-22 23:29   ` Jeff Johnson

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=20250108005854.2973184-2-sboyd@kernel.org \
    --to=sboyd@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=patches@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).