Re: gpio_chip::ngpio vs. gpio_dev::ngpio

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

 



On Mon, May 3, 2021 at 5:03 PM Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:
> On Mon, May 3, 2021 at 3:20 PM Andy Shevchenko
> <andy.shevchenko@xxxxxxxxx> wrote:
>
> > Any shed of light what the difference is (between gpio_chip::ngpio and
> > gpio_dev::ngpio)?
>
> The one in gpio_dev::ngpio is used when referring to that struct
> so it could be renamed ndesc to clarify the usecase.

It would be nice to have it renamed and better described in the kernel doc.
Esp. taking into account the lifetime of each of them.

(Sounds like a new item to somebody's, yours?, TODO list, after
cleaning that gpio_is_valid() thingy :-)

> The gpiochip ngpio i.e. gdev->chip->ngpio cannot be used, because
> sometimes the gpio_chip goes away but not the gpio_dev.
>
> A typical case when this happens is when a gpio_chip and
> corresponding gpio_dev is created by plugging in a USB-based
> gpio device such as FTDI. Then the user start some gpio-event-mon
> or gpio-hammer on that gpio_dev, flickering a LED or something.
>
> If the user unplugs the USB device, the gpio_chip will disappear
> and get "numbed" so that no operations reach the hardware, but
> the userspace program will not end or crash.
>
> When the user finals terminates the program with e.g. ctrl+C
> the character device is closed and gpio_dev goes away and
> for that the ngpio field is needed.

Thanks! It all makes sense to me.

-- 
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