Re: [PATCH v3 04/11] gpiolib: provide gpio_device_find_by_label()

From: Bartosz Golaszewski
Date: Wed Sep 27 2023 - 09:57:18 EST


On Wed, Sep 27, 2023 at 3:48 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Wed, Sep 27, 2023 at 02:42:28PM +0200, Bartosz Golaszewski wrote:
> > On Wed, Sep 27, 2023 at 2:33 PM Andy Shevchenko
> > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > > On Wed, Sep 27, 2023 at 01:22:36PM +0200, Bartosz Golaszewski wrote:
> > > > On Mon, Sep 18, 2023 at 9:19 AM Andy Shevchenko
> > > > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > > > > On Fri, Sep 15, 2023 at 05:03:19PM +0200, Bartosz Golaszewski wrote:
> > > > > > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
>
> ...
>
> > > > > > +static int gpio_chip_match_by_label(struct gpio_chip *gc, void *label)
> > > > > > +{
> > > > > > + return gc->label && !strcmp(gc->label, label);
> > > > > > +}
> > > > >
> > > > > I am still wondering if we can oblige providers to have label to be non-empty.
> > > >
> > > > Of course we can. Just bail out of gpiochip_add_data_with_key() if it
> > > > is. But that's material for a different patch.
> > >
> > > Yes, but my point here is that
> > > 1) the current users are already following this requirement;
> > > 2) the enforcement can be done explicitly somewhere (in the register function).
> > >
> > > Is the 1) incorrect assumption?
> >
> > I remember doing a quick glance over GPIO providers and it looks like
> > ALL of them set the label. But I may have missed something. I would
> > start with a warning.
>
> For now I would drop the NULL check. We will have a few weeks to see
> if somebody screams about. Meanwhile we can add the real error message
> patch if no-one complains.

No, I'm not going to potentially break stuff like that as a way to
detect bugs. That's not a hot path, we're not gaining much. Let's add
a warning first, wait for some time, make it an error and then remove
the check.

Bart