Re: [PATCH v12 3/7] gpiolib: of: make fwnode take precedence in struct gpio_chip

From: Bartosz Golaszewski
Date: Mon Dec 06 2021 - 03:41:52 EST


On Fri, Dec 3, 2021 at 9:10 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Fri, Dec 03, 2021 at 08:28:34PM +0100, Bartosz Golaszewski wrote:
> > On Fri, Dec 3, 2021 at 8:04 PM Andy Shevchenko
> > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > > On Fri, Dec 03, 2021 at 08:56:27PM +0200, Andy Shevchenko wrote:
> > > > On Fri, Dec 03, 2021 at 08:51:56PM +0200, Andy Shevchenko wrote:
> > > > > On Fri, Dec 03, 2021 at 02:29:59PM +0100, Bartosz Golaszewski wrote:
>
> ...
>
> > > > > > if (gc->parent)
> > > > > > gdev->dev.of_node = gc->parent->of_node;
> > > > > >
> > > > > > + if (gc->fwnode)
> > > > > > + gc->of_node = to_of_node(gc->fwnode);
> > > > > > +
> > > > > > /* If the gpiochip has an assigned OF node this takes precedence */
> > > > > > if (gc->of_node)
> > > > > > gdev->dev.of_node = gc->of_node;
> > > > >
> > > > > Similar should be done in acpi_gpio_dev_init():
>
>
> ^^^^^^ (1)
>
> ...
>
> > > If we have parent device for several GPIO devices, this won't work right now
> > > due to limitations of fwnode regarding to the sturct device.
> > >
> > > So, it means we may not have shared primary with different secondary fwnodes.
> > >
> > > So, come back to the initial suggestion (overwrite it for now):
> > >
> > > /*
> > > * If custom fwnode provided, use it. Currently we may not
> > > * handle the case where shared primary node has different
> > > * secondary ones. Ideally we have to use
> > > * set_secondary_fwnode() here.
> > > */
> > > if (gc->fwnode)
> > > device_set_node(&gdev->dev, gc->fwnode);
> > >
> >
> > Other parts of gpiolib-of depend on the of_node being there.
> > Converting it to fwnode is a whole other task so for now I suggest we
> > just convert the fwnode to of_node in struct gpio_chip as per my
> > patch.
>
> But this is about ACPI counterpart. If you do this, do this in both cases.
> Above code for ACPI (1).
>

This series concerns the gpio-sim driver and it only uses configfs
(with manually created platform devices) or device-tree. I would
prefer to do ACPI separately and I'd like you to lead that because I
neither have any HW to test nor claim to understand it. :)

Bart