[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdUq3qZqVHH-QSVnwemVRyCp7b2Ldd-7Q2V8CXcj0+9aow@mail.gmail.com>
Date: Tue, 1 Feb 2022 21:53:58 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Mikko Salomäki <ms@...arespons.se>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpio: aggregator: Fix calling into sleeping GPIO controllers
Hi Andy,
On Tue, Feb 1, 2022 at 9:35 PM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
> On Tue, Feb 1, 2022 at 10:09 PM Geert Uytterhoeven
> <geert+renesas@...der.be> wrote:
> > If the parent GPIO controller is a sleeping controller (e.g. a GPIO
> > controller connected to I2C), getting or setting a GPIO triggers a
> > might_sleep() warning. This happens because the GPIO Aggregator takes
> > the can_sleep flag into account only for its internal locking, not for
> > calling into the parent GPIO controller.
> >
> > Fix this by using the gpiod_[gs]et*_cansleep() APIs when calling into a
> > sleeping GPIO controller.
>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>
Thanks!
> > +++ b/drivers/gpio/gpio-aggregator.c
> > @@ -278,7 +278,8 @@ static int gpio_fwd_get(struct gpio_chip *chip, unsigned int offset)
> > {
> > struct gpiochip_fwd *fwd = gpiochip_get_data(chip);
> >
> > - return gpiod_get_value(fwd->descs[offset]);
>
> > + return chip->can_sleep ? gpiod_get_value_cansleep(fwd->descs[offset])
> > + : gpiod_get_value(fwd->descs[offset]);
>
> This indentation kills the perfectionist in me :-)
Why? The above is aligned perfectly ("?" just above ":")?
> What about:
>
> return chip->can_sleep ?
> gpiod_get_value_cansleep(fwd->descs[offset]) :
> gpiod_get_value(fwd->descs[offset]);
>
> ?
>
> Or as variant
>
> struct gpio_desc *desc = fwd->descs[offset];
>
> return chip->can_sleep ? gpiod_get_value_cansleep(desc) :
> gpiod_get_value(desc);
>
> ?
IMHO, those are ugly as hell ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists