Re: [PATCH v2 4/9] gpio: swnode: don't use the swnode's name as the key for GPIO lookup

From: Bartosz Golaszewski

Date: Fri Oct 24 2025 - 03:21:21 EST


On Wed, Oct 22, 2025 at 8:44 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Wed, Oct 22, 2025 at 03:41:03PM +0200, Bartosz Golaszewski wrote:
> >
> > Looking up a GPIO controller by label that is the name of the software
> > node is wonky at best - the GPIO controller driver is free to set
> > a different label than the name of its firmware node. We're already being
> > passed a firmware node handle attached to the GPIO device to
> > swnode_get_gpio_device() so use it instead for a more precise lookup.
>
> ...
>
> > static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
> > {
> > + struct gpio_device *gdev __free(gpio_device_put) =
> > + gpio_device_find_by_fwnode(fwnode);
> > + if (!gdev)
> > + return ERR_PTR(-EPROBE_DEFER);
> >
> > /*
> > * Check for a special node that identifies undefined GPIOs, this is
> > * primarily used as a key for internal chip selects in SPI bindings.
> > */
> > if (IS_ENABLED(CONFIG_GPIO_SWNODE_UNDEFINED) &&
> > + !strcmp(fwnode_get_name(fwnode), GPIOLIB_SWNODE_UNDEFINED_NAME))
> > return ERR_PTR(-ENOENT);
>
> Now we might get EPROBE_DEREF for the cases when previously it was ENOENT.
> Why is this not a problem? (I haven't found the answer neither in the comment
> above, nor in the commit message)
>

Yeah, maybe it should only change the last part from looking up by
label to looking up by fwnode and leave the previous checks in place.

Bart