On Mon, 29 Jun 2026 17:58:16 +0200, Andy Shevchenko
<[email protected]> said:
> On Mon, Jun 29, 2026 at 12:52:10PM +0200, Bartosz Golaszewski wrote:
>> The software node fw_devlink support already has its own kunit suite, but
>> that verifies the fwnode links in isolation. Add GPIO tests that prove
>> the ordering works in a real-life use-case: a GPIO consumer that
>> references its provider via a software node.
>>
>> The first suite registers the provider's software node, adds the consumer
>> device first and checks that fw_devlink defers its probe until the
>> provider has been added and bound. The second covers the fallback:
>> with the provider's software node not yet registered no supplier link is
>> created, so the consumer probes, devm_gpiod_get() returns -EPROBE_DEFER
>> and the consumer only binds once the provider shows up.
>>
>> While at it: the existing gpio_unbind_with_consumers() test keeps the
>> consumer bound while the provider goes away and then operates the orphaned
>> descriptor. With software nodes now being covered by fw_devlink that would
>> instead force-unbind the consumer along with the provider, so opt it out
>> by setting FWNODE_FLAG_LINKS_ADDED.
>
> ...
>
> + cleanup.h // guard()()
> + err.h // IS_ERR()
>
>>  #include <linux/platform_device.h>
>>  #include <linux/property.h>
>
> + types.h // bool
>
>> +#include <kunit/fwnode.h>
>>  #include <kunit/platform_device.h>
>>  #include <kunit/test.h>
>
> ...
>
>> +    properties[1] = (struct property_entry){ };
>
> Just zero the whole array at the definition time.
>
> ...
>
>> +    pdevinfo = (struct platform_device_info){
>
> It's better to have a space after ).
>

TBH most compound literals in the kernel seem to not add the space.

>> +            .name = GPIO_PROBE_ORDER_TEST_CONSUMER,
>> +            .id = PLATFORM_DEVID_NONE,
>> +            .data = &gpio_probe_order_pdata_template,
>> +            .size_data = sizeof(gpio_probe_order_pdata_template),
>> +            .properties = properties,
>> +    };
>
> ...
>
>> +    pdevinfo = (struct platform_device_info){
>
> Ditto.
>
>> +            .name = GPIO_TEST_PROVIDER,
>> +            .id = PLATFORM_DEVID_NONE,
>> +            .swnode = &gpio_test_provider_swnode,
>> +    };
>
> ...
>
>> +struct gpio_probe_defer_pdata {
>> +    int probe_count;
>
> Why is this signed?
>
>> +    int gpio_err;
>> +};
>
> ...
>
>> +static int gpio_probe_defer_consumer_probe(struct platform_device *pdev)
>> +{
>> +    struct device *dev = &pdev->dev;
>> +    struct gpio_probe_defer_pdata *pdata = dev_get_platdata(dev);
>> +    struct gpio_desc *desc;
>
>> +    pdata->probe_count++;
>
> Even in case of error?
>

We're counting how many times we *enter* probe, so yes, I think it's right.

Bart

Reply via email to