From: Stephen Boyd <sboyd@kernel.org>
To: Chen-Yu Tsai <wenst@chromium.org>
Cc: Chen-Yu Tsai <wenst@chromium.org>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Brian Masney <bmasney@redhat.com>
Subject: Re: [PATCH RESEND v2] clk: tests: Add tests for clk lookup by name
Date: Sat, 18 Apr 2026 11:26:05 -0700 [thread overview]
Message-ID: <177653676535.5403.14630700858352386940@localhost.localdomain> (raw)
In-Reply-To: <20260225083413.3384950-1-wenst@chromium.org>
Quoting Chen-Yu Tsai (2026-02-25 00:34:11)
> Clk lookup (by name) recently gained some performance improvements at
> the expense of more complexity within the lookup code.
>
> To make sure that this works as intended and doesn't break, add some
> basic tests for this part of the CCF.
>
> A new "clk_hw_lookup()" function is added purely for running kunit
> tests.
>
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
>
> ---
Thanks. One nit below that I can likely fix before merging unless you
send again.
> diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c
> index a268d7b5d4cb..a8989566946b 100644
> --- a/drivers/clk/clk_test.c
> +++ b/drivers/clk/clk_test.c
> @@ -175,6 +175,8 @@ static const struct clk_ops clk_multiple_parents_no_reparent_mux_ops = {
> .set_parent = clk_multiple_parents_mux_set_parent,
> };
>
> +#define DUMMY_CLK_NAME "test_dummy_rate"
> +
> static int clk_test_init_with_ops(struct kunit *test, const struct clk_ops *ops)
> {
> struct clk_dummy_context *ctx;
> @@ -187,7 +189,7 @@ static int clk_test_init_with_ops(struct kunit *test, const struct clk_ops *ops)
> ctx->rate = DUMMY_CLOCK_INIT_RATE;
> test->priv = ctx;
>
> - init.name = "test_dummy_rate";
> + init.name = DUMMY_CLK_NAME;
> init.ops = ops;
> ctx->hw.init = &init;
>
> @@ -3541,6 +3543,67 @@ static struct kunit_suite clk_hw_get_dev_of_node_test_suite = {
> .test_cases = clk_hw_get_dev_of_node_test_cases,
> };
>
> +/*
> + * Test that clk lookup with a name that is not registered returns NULL.
> + */
> +static void clk_lookup_not_registered_clk_returns_NULL(struct kunit *test)
> +{
> + KUNIT_EXPECT_PTR_EQ(test, NULL, clk_hw_lookup(DUMMY_CLK_NAME));
> +}
> +
> +/*
> + * Test that clk lookup with a name that is registered returns the clk.
> + */
> +static void clk_lookup_registered_clk_returns_clk(struct kunit *test)
> +{
> + struct clk_hw *hw;
> + struct clk_init_data init = {
> + .name = DUMMY_CLK_NAME,
> + .ops = &empty_clk_ops,
> + };
> +
> + hw = kunit_kzalloc(test, sizeof(*hw), GFP_KERNEL);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw);
> +
> + hw->init = &init;
> + KUNIT_ASSERT_EQ(test, 0, clk_hw_register_kunit(test, NULL, hw));
> +
> + KUNIT_EXPECT_PTR_EQ(test, hw, clk_hw_lookup(DUMMY_CLK_NAME));
> +}
> +
> +/*
> + * Test that clk lookup with a name that was unregistered returns NULL.
> + */
> +static void clk_lookup_unregistered_clk_returns_NULL(struct kunit *test)
> +{
> + struct clk_hw *hw;
> + struct clk_init_data init = {
> + .name = DUMMY_CLK_NAME,
> + .ops = &empty_clk_ops,
> + };
> +
> + hw = kunit_kzalloc(test, sizeof(*hw), GFP_KERNEL);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw);
> +
> + hw->init = &init;
> + KUNIT_ASSERT_FALSE(test, clk_hw_register(NULL, hw));
Should be
KUNIT_ASSERT_EQ(test, 0, clk_hw_register(NULL, hw))
because clk_hw_register() returns an int.
> +
> + clk_hw_unregister(hw);
> +
> + KUNIT_EXPECT_PTR_EQ(test, NULL, clk_hw_lookup(DUMMY_CLK_NAME));
> +}
prev parent reply other threads:[~2026-04-18 18:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 8:34 Chen-Yu Tsai
2026-02-25 13:24 ` Brian Masney
2026-04-18 18:26 ` Stephen Boyd [this message]
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=177653676535.5403.14630700858352386940@localhost.localdomain \
--to=sboyd@kernel.org \
--cc=bmasney@redhat.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wenst@chromium.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
all inboxes | Powered by JetHome®