From: Brian Masney <bmasney@redhat.com>
To: Stephen Boyd <sboyd@kernel.org>, Maxime Ripard <mripard@kernel.org>
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Arnd Bergmann <arnd@arndb.de>,
Thomas Gleixner <tglx@linutronix.de>,
Michael Turquette <mturquette@baylibre.com>,
Alberto Ruiz <aruiz@redhat.com>,
Brian Masney <bmasney@redhat.com>
Subject: [PATCH v2 04/10] clk: test: introduce clk_dummy_div for a mock divider
Date: Wed, 28 May 2025 19:16:50 -0400 [thread overview]
Message-ID: <20250528-clk-wip-v2-v2-4-0d2c2f220442@redhat.com> (raw)
In-Reply-To: <20250528-clk-wip-v2-v2-0-0d2c2f220442@redhat.com>
This is used to mock up a divider in the clk kunit tests.
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
drivers/clk/clk_test.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c
index 1b34d54ec9c610ffa3e91b06f5a5180e0395e26f..4908fb9c0c46e34063ecf696e49b48510da44538 100644
--- a/drivers/clk/clk_test.c
+++ b/drivers/clk/clk_test.c
@@ -140,6 +140,47 @@ static const struct clk_ops clk_dummy_single_parent_ops = {
.get_parent = clk_dummy_single_get_parent,
};
+// 4 ought to be enough for anybody
+#define CLK_DUMMY_DIV_WIDTH 4
+
+struct clk_dummy_div {
+ struct clk_hw hw;
+ unsigned int div;
+};
+
+static unsigned long clk_dummy_div_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct clk_dummy_div *div = container_of(hw, struct clk_dummy_div, hw);
+
+ return divider_recalc_rate(hw, parent_rate, div->div, NULL,
+ CLK_DIVIDER_ROUND_CLOSEST, CLK_DUMMY_DIV_WIDTH);
+}
+
+static long clk_dummy_div_round_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long *parent_rate)
+{
+ return divider_round_rate(hw, rate, parent_rate, NULL,
+ CLK_DUMMY_DIV_WIDTH, CLK_DIVIDER_ROUND_CLOSEST);
+}
+
+static int clk_dummy_div_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ struct clk_dummy_div *div = container_of(hw, struct clk_dummy_div, hw);
+
+ div->div = divider_get_val(rate, parent_rate, NULL, CLK_DUMMY_DIV_WIDTH,
+ CLK_DIVIDER_ROUND_CLOSEST);
+
+ return 0;
+}
+
+static const struct clk_ops clk_dummy_div_ops = {
+ .recalc_rate = clk_dummy_div_recalc_rate,
+ .round_rate = clk_dummy_div_round_rate,
+ .set_rate = clk_dummy_div_set_rate,
+};
+
struct clk_multiple_parent_ctx {
struct clk_dummy_context parents_ctx[2];
struct clk_hw hw;
--
2.49.0
next prev parent reply other threads:[~2025-05-28 23:17 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-28 23:16 [PATCH v2 00/10] clk: add kunit tests and correct rate change bug in the clk core Brian Masney
2025-05-28 23:16 ` [PATCH v2 01/10] clk: add kernel docs for struct clk_core Brian Masney
2025-06-06 9:17 ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 02/10] clk: preserve original rate when a sibling clk changes it's rate Brian Masney
2025-06-06 8:55 ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 03/10] clk: test: introduce a few specific rate constants for mock testing Brian Masney
2025-06-06 8:56 ` Maxime Ripard
2025-06-06 14:28 ` Brian Masney
2025-06-10 16:28 ` Maxime Ripard
2025-05-28 23:16 ` Brian Masney [this message]
2025-06-06 9:00 ` [PATCH v2 04/10] clk: test: introduce clk_dummy_div for a mock divider Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 05/10] clk: test: introduce test suite for sibling rate changes on a divider Brian Masney
2025-06-10 15:39 ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 06/10] clk: test: introduce clk_dummy_gate for a mock gate Brian Masney
2025-06-06 8:13 ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 07/10] clk: test: introduce test suite for sibling rate changes on a gate Brian Masney
2025-06-10 16:05 ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 08/10] clk: test: introduce helper to create a mock mux Brian Masney
2025-06-10 16:20 ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 09/10] clk: test: introduce test variation for sibling rate changes on a mux Brian Masney
2025-05-28 23:16 ` [PATCH v2 10/10] clk: test: introduce test variation for sibling rate changes on a gate/mux Brian Masney
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=20250528-clk-wip-v2-v2-4-0d2c2f220442@redhat.com \
--to=bmasney@redhat.com \
--cc=arnd@arndb.de \
--cc=aruiz@redhat.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®