[PATCH v3 03/10] gpiolib: implement low-level, shared GPIO support

Andy Shevchenko andriy.shevchenko at intel.com
Wed Oct 29 08:18:49 PDT 2025


On Wed, Oct 29, 2025 at 01:39:34PM +0100, Bartosz Golaszewski wrote:
> On Wed, Oct 29, 2025 at 12:45 PM Andy Shevchenko
> <andriy.shevchenko at intel.com> wrote:
> > On Wed, Oct 29, 2025 at 12:20:39PM +0100, Bartosz Golaszewski wrote:
> > >
> > > This module scans the device tree (for now only OF nodes are supported
> > > but care is taken to make other fwnode implementations easy to
> > > integrate) and determines which GPIO lines are shared by multiple users.
> > > It stores that information in memory. When the GPIO chip exposing shared
> > > lines is registered, the shared GPIO descriptors it exposes are marked
> > > as shared and virtual "proxy" devices that mediate access to the shared
> > > lines are created. When a consumer of a shared GPIO looks it up, its
> > > fwnode lookup is redirected to a just-in-time machine lookup that points
> > > to this proxy device.
> > >
> > > This code can be compiled out on platforms which don't use shared GPIOs.
> >
> > Besides strcmp_suffix() that already exists in OF core, there are also some
> > existing pieces that seems being repeated here (again). Can we reduce amount
> > of duplication?
> 
> I'm afraid you need to be more specific here.

You can simply browse the file, it's not long to find and think about it.
I'm _thinking_ that it's possible to improve the situation overall by
try our best of deduplicating (or rather not duplicating) things.

...

> > > +#if IS_ENABLED(CONFIG_OF)
> > > +static int gpio_shared_of_traverse(struct device_node *curr)
> > > +{
> >
> > I believe parts of this code may be resided somewhere in drivers/of/property.c
> > or nearby as it has the similar parsing routines.
> 
> I don't think this is a good idea, I want to keep it within the
> confines of drivers/gpio/ and the use-case is so specific, there's
> really no point in putting parts of it under drivers/of/.
> 
> If I could only iterate over all properties of an fwnode, I'd have
> skipped using OF-specific routines altogether.

The problem is that every subsystem considers "it's not a good idea" or
"historical reasons" or other excuses. Since you are adding OF-specific
stuff that has something already done inside OF specific code, why to
spread it over the kernel by duplicating in another place(s)?

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-arm-kernel mailing list