Re: [PATCH v2 21/23] gpio: protect the pointer to gpio_chip in gpio_device with SRCU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 05, 2024 at 08:36:39PM +0100, Bartosz Golaszewski wrote:
> On Mon, Feb 5, 2024 at 1:31 PM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

...

> >
> > >  int gpiod_get_direction(struct gpio_desc *desc)
> > >  {
> > > -     struct gpio_chip *gc;
> > >       unsigned long flags;
> > >       unsigned int offset;
> > >       int ret;
> > >
> > > -     gc = gpiod_to_chip(desc);
> > > +     if (!desc)
> > > +             /* Sane default is INPUT. */
> > > +             return 1;
> >
> > Hmm... I can't imagine how this value may anyhow be used / useful.
> 
> What else would you return for an optional (NULL) GPIO?

An error. If somebody asks for direction of the non-existing GPIO, there is no
(valid) answer for that.

-- 
With Best Regards,
Andy Shevchenko






[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux