archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <>
To: Saravana Kannan <>
Cc: Bartosz Golaszewski <>,
	Greg Kroah-Hartman <>,
	Marc Zyngier <>,
	Jisheng Zhang <>,
	Kever Yang <>,
	Android Kernel Team <>,
	"open list:GPIO SUBSYSTEM" <>,
	"" <>
Subject: Re: [PATCH v2] gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default
Date: Fri, 22 Jan 2021 14:04:35 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Thu, Jan 21, 2021 at 8:43 PM Saravana Kannan <> 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

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.


Linus Walleij

  reply	other threads:[~2021-01-22 13:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-16  1:14 [PATCH v2] gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default Saravana Kannan
2021-01-16 20:37 ` Andy Shevchenko
2021-01-17 12:02 ` Marc Zyngier
2021-01-18 20:38   ` Saravana Kannan
2021-01-20 15:39     ` Marc Zyngier
2021-01-20 15:48       ` Greg Kroah-Hartman
2021-01-20 15:58         ` Marc Zyngier
2021-01-20 17:01           ` Greg Kroah-Hartman
2021-01-21 13:00 ` Linus Walleij
2021-01-21 19:43   ` Saravana Kannan
2021-01-22 13:04     ` Linus Walleij [this message]
2021-01-22 19:35 [PATCH v5] " Saravana Kannan
     [not found] ` <>
2021-01-26 18:16   ` [PATCH v2] " Saravana Kannan
2021-01-26 18:32     ` Andy Shevchenko

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:

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

  git send-email \
    --in-reply-to='' \ \ \ \ \ \ \ \ \ \ \

* 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;
as well as URLs for NNTP newsgroup(s).