Re: [PATCH v5 8/8] reset: gpio: use software nodes to setup the GPIO lookup

From: Andy Shevchenko

Date: Wed Nov 05 2025 - 09:10:36 EST


On Wed, Nov 05, 2025 at 09:47:39AM +0100, Bartosz Golaszewski wrote:
>
> GPIO machine lookup is a nice mechanism for associating GPIOs with
> consumers if we don't know what kind of device the GPIO provider is or
> when it will become available. However in the case of the reset-gpio, we
> are already holding a reference to the device and so can reference its
> firmware node. Let's setup a software node that references the relevant
> GPIO and attach it to the auxiliary device we're creating.

...

> static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
> {
> + struct property_entry properties[] = { {}, {} };

It's an interesting way of saying this?

struct property_entry properties[2] = { };

> struct reset_gpio_lookup *rgpio_dev;
> + unsigned int offset, of_flags;
> + struct device *parent;
> + int id, ret, lflags;

I assumed that lflags shouldn't be signed. And IIRC they are unsigned long
elsewhere (yes, just confirmed).

...

> + rgpio_dev->swnode = fwnode_create_software_node(properties, NULL);
> + if (IS_ERR(rgpio_dev->swnode)) {
> + ret = PTR_ERR(rgpio_dev->swnode);
> + goto err_put_of_node;
> + }

Can save 1 LoC?

rgpio_dev->swnode = fwnode_create_software_node(properties, NULL);
ret = PTR_ERR_OR_ZERO(rgpio_dev->swnode);
if (ret)
goto err_put_of_node;

--
With Best Regards,
Andy Shevchenko