public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Bartosz Golaszewski <brgl@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Linus Walleij <linusw@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Daniel Scally <djrscally@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Len Brown <lenb@kernel.org>,
	driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH v2 2/2] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
Date: Tue, 24 Feb 2026 11:43:39 +0200	[thread overview]
Message-ID: <aZ1yyxshteYU2BAg@smile.fi.intel.com> (raw)
In-Reply-To: <aZ1nsPX36Y5DuDpr@kekkonen.localdomain>

On Tue, Feb 24, 2026 at 10:56:16AM +0200, Sakari Ailus wrote:
> On Tue, Feb 24, 2026 at 09:47:57AM +0100, Bartosz Golaszewski wrote:
> > On Mon, Feb 23, 2026 at 11:07 PM Sakari Ailus
> > <sakari.ailus@linux.intel.com> wrote:

...

> > > > > >  static int gpio_chip_match_by_fwnode(struct gpio_chip *gc, const void *fwnode)
> > > > > >  {
> > > > > > -     return device_match_fwnode(&gc->gpiodev->dev, fwnode);
> > > > > > +     struct device *dev = &gc->gpiodev->dev;
> > > > > > +     struct fwnode_handle *node = dev_fwnode(dev);
> > > > > > +
> > > > > > +     if (IS_ERR(fwnode))
> > > > > > +             return 0;
> > > > > > +
> > > > > > +     if (device_match_fwnode(dev, fwnode))
> > > > >
> > > > > Could device_match_fwnode() match secondary fwnode as well?
> > > >
> > > > In the previous discussion on this, Andy was against doing that due to
> > > > the concern that it might introduce subtle bugs, which I agree with.
> > >
> > > Could you elaborate or provide an example?

I believe you ask me. Okay, the sophisticated case I have in mind is the
intel_quark_i2c_gpio.c which provides a GPIO device with a list of children.

First of all, it seems broken as it rewrites the secondary link for the
I²C device. (Which makes me think that we need to have a copy of the
[primary] fwnode in the children devices of MFD, but I don't know how
to refcount that properly). The gpiolib-acpi-core.c has a matching function
via ACPI_HANDLE(). So it might be not affected by this.

What I don't know is USB Type-C and USB DWC3 code where it's much more
complicated. And I'm not in a position to state that the change won't
affect those.

> > > The function has some 27 users although few are individual drivers.
> > >
> > > My understanding is that we only have the secondary fwnode for being able
> > > to attach objects from different backend to the same node. The fwnode API
> > > in the meantime generally tries to hide the existence of the secondary
> > > fwnode; a rewrite (which ideally would have happened perhaps a few years
> > > ago?) would probably make the fwnode a linked list instead so we'd lose
> > > that secondary pointer in the process.
> > 
> > It already is a (singly) linked list. Ideally it would be a
> 
> With two entries at most.

There is no technical limitation based on the data type.

> > doubly-linked list moved into struct device with struct fwnode_handle
> > having no concept of primary and secondary nodes.
> 
> I'd think we had that list in struct fwnode_handle, which will still
> represent nodes. But let's see the details when someone gets to implement
> it. :-)

In the case above single or double linked list doesn't solve the issue of
the corrupted (parent) fwnode. We need also to have a siblings list so it
looks more like a tree.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-02-24  9:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 15:40 [PATCH v2 0/2] driver core: provide and use device_match_fwnode_ext() Bartosz Golaszewski
2026-02-23 15:40 ` [PATCH v2 1/2] driver core: make fwnode_is_primary() public Bartosz Golaszewski
2026-02-23 15:42   ` Rafael J. Wysocki
2026-02-23 17:53   ` Dmitry Torokhov
2026-02-23 17:54   ` Andy Shevchenko
2026-02-23 18:28     ` Bartosz Golaszewski
2026-02-23 18:49       ` Rafael J. Wysocki
2026-02-23 19:32       ` Andy Shevchenko
2026-02-23 19:45         ` Rafael J. Wysocki
2026-02-23 20:24           ` Andy Shevchenko
2026-02-23 15:40 ` [PATCH v2 2/2] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode() Bartosz Golaszewski
2026-02-23 15:43   ` Rafael J. Wysocki
2026-02-23 17:23   ` Sakari Ailus
2026-02-23 17:46     ` Rafael J. Wysocki
2026-02-23 22:07       ` Sakari Ailus
2026-02-24  8:47         ` Bartosz Golaszewski
2026-02-24  8:56           ` Sakari Ailus
2026-02-24  9:43             ` Andy Shevchenko [this message]
2026-02-25  7:39               ` Sakari Ailus
2026-02-25  9:38                 ` Andy Shevchenko
2026-02-25 10:07                   ` Heikki Krogerus
2026-02-23 19:45   ` Danilo Krummrich
2026-02-23 19:55     ` Rafael J. Wysocki
2026-02-23 20:00       ` Danilo Krummrich
2026-02-23 20:04         ` Rafael J. Wysocki
2026-02-23 20:46   ` Rafael J. Wysocki
2026-02-23 15:46 ` [PATCH v2 0/2] driver core: provide and use device_match_fwnode_ext() Bartosz Golaszewski
2026-02-23 16:00   ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aZ1yyxshteYU2BAg@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=dakr@kernel.org \
    --cc=djrscally@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=lenb@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox