Re: [PATCH v2] gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 21, 2021 at 8:43 PM Saravana Kannan <saravanak@xxxxxxxxxx> wrote:

> > They may still have "ports" or "banks" of GPIO that make sense
> > to separate into logical nodes and this is most often why they
> > do this.
> >
> > I bet there are some other oddities as well.
>
> Ah, thanks for the context. But couldn't they just skip the
> "compatible" property in the DT if these individual nodes aren't
> considered separate devices? It's too late for existing DT device
> bindings, but maybe in the future we can ask them to skip the
> "compatible" property if they don't consider the sub nodes to be
> distinct devices?

That makes sense and has been done in other cases.

> > > This patch works around this problem and avoids all the code churn by
> > > simply creating a stub driver to bind to the gpio_device. Since the
> > > gpio_device already points to the GPIO device tree node, this allows all
> > > the consumers to continue probing when the driver follows case 2.
> >
> > That makes sense.
> >
> > > If/when all the old drivers are refactored, we can revert this patch.
> >
> > I have a bad feeling about this.
> >
> > This type of hacks tend to stay around forever.
> >
> > That said I'm not sure this is entirely wrong either, maybe this
> > is business as usual and *should* stay around forever. Haven't
> > made my mind up about that.
>
> Considering your comment about why some (not all) of these nodes
> aren't considered separate devices, looks like this has to stay this
> way forever? I can drop this line in the commit text.

Yep looks like so. I think this patch is sound.

> > You need to put code into drivers/gpio/gpiolib-of.c with stubs
> > for the !OF case in drivers/gpio/gpiolib-of.h so that systems
> > not using device tree can avoid this code path.
>
> It's not clear in the diff due to lack of sufficient context lines,
> but this piece of code is already inside a #ifdef CONFIG_OF_GPIO.
>
> To cover the case where CONFIG_OF_GPIO is enabled but we get here for
> non-DT devices, I just need to add a !fwnode check here. Then stuff
> will automatically NOP out for non-DT devices. Since the
> gdev->dev.of_node is set a few lines above, I think gdev->dev.fwnode
> should also be set close to it (which is what the next few lines do).
> I'll add this additional check to v3.

I dunno about that. If you add more than a few lines of DT-specific
code, I prefer that you put that into gpiolib-of.c to keep things
separate, or we will get a mess with more and more hardware
descriptions.

Things that are agnostic fwnode is fine to have in generic code,
it should be used the same by pretty much anything.

A matter of taste I suppose, so no strong opinion.

> > As discussed in other messages I don't know if this message
> > is aligned with the device tree ontology. The DT people should
> > speak about that.
>
> Considering what you said earlier, I'll just drop this message.

Thanks.

Yours,
Linus Walleij



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux