From: Maxime Ripard <mripard@kernel.org>
To: Brian Masney <bmasney@redhat.com>
Cc: Stephen Boyd <sboyd@kernel.org>,
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>
Subject: Re: [PATCH v2 08/10] clk: test: introduce helper to create a mock mux
Date: Tue, 10 Jun 2025 18:20:36 +0200 [thread overview]
Message-ID: <20250610-heavy-liberal-moose-dba76e@houat> (raw)
In-Reply-To: <20250528-clk-wip-v2-v2-8-0d2c2f220442@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3086 bytes --]
On Wed, May 28, 2025 at 07:16:54PM -0400, Brian Masney wrote:
> Introduce a helper to create a mock mux to reduce code duplication.
> This also changes it so that the relevant clk_hws are registered with
> the kunit framework.
>
> Signed-off-by: Brian Masney <bmasney@redhat.com>
> ---
> drivers/clk/clk_test.c | 141 ++++++++++++++++++-------------------------------
> 1 file changed, 52 insertions(+), 89 deletions(-)
>
> diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c
> index 1440eb3c41def8c549f92c0e95b2a472f3bdb4a7..147935975969f8da4a9365c0fac6ffe37e310933 100644
> --- a/drivers/clk/clk_test.c
> +++ b/drivers/clk/clk_test.c
> @@ -538,45 +538,64 @@ static struct kunit_suite clk_uncached_test_suite = {
> .test_cases = clk_uncached_test_cases,
> };
>
> -static int
> -clk_multiple_parents_mux_test_init(struct kunit *test)
> -{
> - struct clk_multiple_parent_ctx *ctx;
> - const char *parents[2] = { "parent-0", "parent-1"};
> +static int clk_init_multiple_parent_ctx(struct kunit *test,
> + struct clk_multiple_parent_ctx *ctx,
> + const char *parent0_name,
> + unsigned long parent0_rate,
> + const char *parent1_name,
> + unsigned long parent1_rate,
> + const char *mux_name, int mux_flags,
> + const struct clk_ops *mux_ops)
> +{
> + const struct clk_hw *parents[2];
> int ret;
>
> - ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL);
> - if (!ctx)
> - return -ENOMEM;
> - test->priv = ctx;
> -
> - ctx->parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT("parent-0",
> + ctx->parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT(parent0_name,
> &clk_dummy_rate_ops,
> 0);
> - ctx->parents_ctx[0].rate = DUMMY_CLOCK_RATE_1;
> + ctx->parents_ctx[0].rate = parent0_rate;
> ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[0].hw);
> if (ret)
> return ret;
>
> - ctx->parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("parent-1",
> + ctx->parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT(parent1_name,
> &clk_dummy_rate_ops,
> 0);
> - ctx->parents_ctx[1].rate = DUMMY_CLOCK_RATE_2;
> + ctx->parents_ctx[1].rate = parent1_rate;
> ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[1].hw);
> if (ret)
> return ret;
>
> - ctx->current_parent = 0;
> - ctx->hw.init = CLK_HW_INIT_PARENTS("test-mux", parents,
> - &clk_multiple_parents_mux_ops,
> - CLK_SET_RATE_PARENT);
> + parents[0] = &ctx->parents_ctx[0].hw;
> + parents[1] = &ctx->parents_ctx[1].hw;
> + ctx->hw.init = CLK_HW_INIT_PARENTS_HW(mux_name, parents,
> + mux_ops, mux_flags);
> ret = clk_hw_register_kunit(test, NULL, &ctx->hw);
> if (ret)
> return ret;
>
> + ctx->current_parent = 0;
> +
> return 0;
> }
In this patch too, I'm wondering if we're not making it more complex
than it needs to be. I can see how small variations (like the parent
flags, or ops, or...) will all sound reasonable, but will turn this
allegedly simple function into a large, hard-to-parse, one
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
next prev parent reply other threads:[~2025-06-10 16:20 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 ` [PATCH v2 04/10] clk: test: introduce clk_dummy_div for a mock divider Brian Masney
2025-06-06 9:00 ` 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 [this message]
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=20250610-heavy-liberal-moose-dba76e@houat \
--to=mripard@kernel.org \
--cc=arnd@arndb.de \
--cc=aruiz@redhat.com \
--cc=bmasney@redhat.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.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