Re: [PATCH v3 1/4] clk: add a clk_hw helpers to get the clock device or device_node

From: Jerome Brunet
Date: Fri Mar 21 2025 - 13:54:03 EST


On Wed 26 Feb 2025 at 17:01, Stephen Boyd <sboyd@xxxxxxxxxx> wrote:


>> +static void clk_hw_get_of_node_test(struct kunit *test)
>> +{
>> + struct device_node *np;
>> + struct clk_hw *hw;
>> +
>> + hw = kunit_kzalloc(test, sizeof(*hw), GFP_KERNEL);
>> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw);
>> +
>> + np = of_find_compatible_node(NULL, NULL, "test,clk-dummy-device");
>> + hw->init = CLK_HW_INIT_NO_PARENT("test_get_of_node",
>> + &clk_dummy_rate_ops, 0);
>> + of_node_put_kunit(test, np);
>> +
>> + KUNIT_ASSERT_EQ(test, 0, of_clk_hw_register_kunit(test, np, hw));
>
> The stuff before the expectation should likely go to the init function.
> Or it can use the genparams stuff so we can set some struct members to
> indicate if the pointer should be NULL or not and then twist through the
> code a couple times.
>

I'm trying to address all your comments but I'm starting to wonder if
this isn't going a bit too far ? The functions tested are one line
returns. Is it really worth all this ?

I do understand the idea for things that actually do something, such as
reparenting, setting rates or what not ... But this ? It feels like a
lot of test code for very little added value, don't you think ?

--
Jerome