Re: [PATCH v2 1/1] gpiolib: Introduce for_each_gpio_desc_if() macro
From: Johan Hovold
Date: Thu May 20 2021 - 04:33:43 EST
On Thu, May 20, 2021 at 11:15:31AM +0300, Andy Shevchenko wrote:
> On Thu, May 20, 2021 at 11:07 AM Johan Hovold <johan@xxxxxxxxxx> wrote:
> > On Tue, May 18, 2021 at 11:33:39AM +0300, Andy Shevchenko wrote:
> > The _if suffix here is too vague.
> >
> > Please use a more descriptive name so that you don't need to look at the
> > implementation to understand what the macro does.
> >
> > Perhaps call it
> >
> > for_each_gpio_desc_with_flag()
>
> Haha, I have the same in my internal tree, but then I have changed to
> _if and here is why:
> - the API is solely for internal use (note, internals of struct
> gpio_desc available for the same set of users)
That's not a valid argument here. You should never make code harder to
read.
There are other ways of marking functions as intended for internal use
(e.g. do not export them and add a _ prefix or whatever).
> - the current users do only same pattern
That's not an argument against using a descriptive name. Possibly
against adding a generic for_each_gpio_desc() macro.
> - I don't expect that we will have this to be anything else in the future
Again, irrelevant. Possibly an argument against adding another helper in
the first place.
> Thus, _if is a good balance between scope of use and naming.
No, no, no. It's never a good idea to obfuscate code.
> I prefer to leave it as is.
I hope you'll reconsider, or that my arguments can convince the
maintainers to step in here.
> > or just add the more generic macro
> >
> > for_each_gpio_desc()
> >
> > and open-code the test so that it's clear what's going on here.
FWIW, NAK due to the non-descriptive for_each_desc_if() name.
Johan