mbox series

[v1,0/7] gpiolib: Some cleanups

Message ID 20250415111124.1539366-1-andriy.shevchenko@linux.intel.com
Headers show
Series gpiolib: Some cleanups | expand

Message

Andy Shevchenko April 15, 2025, 11:09 a.m. UTC
Just a three groups of cleanups (some of them may be dependent to the previous
ones, but I am only aware about couple of patches, i.e. 3 & 4).

Andy Shevchenko (7):
  gpiolib: Print actual error when descriptor contains an error pointer
  gpiolib: Revert "Don't WARN on gpiod_put() for optional GPIO"
  gpiolib: Move validate_desc() and Co upper in the code
  gpiolib: Call validate_desc() when VALIDATE_DESC() can't be used
  gpiolib: Make taking gpio_lookup_lock consistent
  gpiolib: Convert to use guard()() for gpio_machine_hogs_mutex
  gpiolib: Remove redundant assignment of return variable

 drivers/gpio/gpiolib.c | 123 ++++++++++++++++++-----------------------
 1 file changed, 53 insertions(+), 70 deletions(-)

Comments

Linus Walleij April 16, 2025, 8:42 a.m. UTC | #1
On Tue, Apr 15, 2025 at 1:11 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Move validate_desc() and Co upper in the code to be able to use
> in the further changes.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Linus Walleij April 16, 2025, 8:47 a.m. UTC | #2
On Tue, Apr 15, 2025 at 1:11 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> In some functions the returned variable is assigned to 0 and then
> reassigned to the actual value. Remove redundant assignments.
>
> In one case make it more clear that the assignment is not needed.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

This is actually really good, because if someone goofs up the code
so that assignment is actually needed then the compiler will
complain. (Arnd told me this.)

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Andy Shevchenko April 16, 2025, 9:17 a.m. UTC | #3
On Wed, Apr 16, 2025 at 10:44:18AM +0200, Linus Walleij wrote:
> On Tue, Apr 15, 2025 at 1:11 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> 
> > Call validate_desc() directly when VALIDATE_DESC() can't be used.
> > It will print additional information useful for debugging.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Thank you!

...

> >         if (gc->to_irq) {
> > -               int retirq = gc->to_irq(gc, offset);
> > +               ret = gc->to_irq(gc, offset);
> > +               if (ret)
> > +                       return ret;
> >
> >                 /* Zero means NO_IRQ */
> > -               if (!retirq)
> > -                       return -ENXIO;
> > -
> > -               return retirq;
> > +               return -ENXIO;
> 
> Totally unrelated change - but I'm fine with that :D

It's not totally (it's a reuse of the same variable), but I can split it.
Bart, what do you prefer?