Re: [PATCH v4 7/7] clk: tests: Add Kunit testing for nexus nodes
From: Miquel Raynal
Date: Fri Aug 07 2026 - 08:51:47 EST
On 21/07/2026 at 18:32:39 -04, Brian Masney <bmasney@xxxxxxxxxx> wrote:
> On Fri, Jul 17, 2026 at 05:59:23PM +0200, Miquel Raynal (Schneider Electric) wrote:
>> Add a nexus node with a child requesting a mapped clock in the fake DT
>> overlay to verify that the parsing is also correctly working.
>>
>> Create an of_find_node_by_name() like kunit helper to garbage collect the
>> node automatically in case of failed assertion.
>>
>> Suggested-by: Stephen Boyd <sboyd@xxxxxxxxxx>
>> Signed-off-by: Miquel Raynal (Schneider Electric) <miquel.raynal@xxxxxxxxxxx>
>> ---
>> drivers/clk/clk_kunit_helpers.c | 31 +++++++++++++++++++++++++++++++
>> drivers/clk/clk_test.c | 15 +++++++++++++++
>> drivers/clk/kunit_clk_parse_clkspec.dtso | 10 ++++++++++
>> include/kunit/clk.h | 2 ++
>> 4 files changed, 58 insertions(+)
>>
>> diff --git a/drivers/clk/clk_kunit_helpers.c b/drivers/clk/clk_kunit_helpers.c
>> index 68a28e70bb61..daaf1cf1546c 100644
>> --- a/drivers/clk/clk_kunit_helpers.c
>> +++ b/drivers/clk/clk_kunit_helpers.c
>> @@ -233,5 +233,36 @@ int of_clk_add_hw_provider_kunit(struct kunit *test, struct device_node *np,
>> }
>> EXPORT_SYMBOL_GPL(of_clk_add_hw_provider_kunit);
>>
>> +KUNIT_DEFINE_ACTION_WRAPPER(of_node_put_wrapper, of_node_put, struct device_node *);
>> +
>> +/**
>> + * of_find_node_by_name_kunit() - Test managed of_find_node_by_name()
>> + * @test: The test context
>> + * @from: Parent device node to start searching from, or NULL to search from root
>> + * @name: The name string to match against
>> + *
>> + * Just like of_find_node_by_name(), except the device_noded is managed by
>> + * the test case and is automatically put after the test case concludes.
>> + *
>> + * Return: the device_node on success, NULL if not found, or a negative errno value on failure.
>> + */
>> +struct device_node *of_find_node_by_name_kunit(struct kunit *test, struct device_node *from,
>> + const char *name)
>> +{
>> + struct device_node *np;
>> + int ret;
>> +
>> + np = of_find_node_by_name(from, name);
>> + if (!np)
>> + return NULL;
>> +
>> + ret = kunit_add_action_or_reset(test, of_node_put_wrapper, np);
>> + if (ret)
>> + return ERR_PTR(ret);
>> +
>> + return np;
>> +}
>> +EXPORT_SYMBOL_GPL(of_find_node_by_name_kunit);
>
> Should this be prefixed with clk_ since this is in
> clk_kunit_helpers.c?
That's right, I missed it. I'll rename the helper.
Thanks!
Miquèl