Re: Is consumer documentation correct?

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

 



On Thu, Oct 22, 2020 at 6:26 PM Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:

> It _seems_ between
>   79a9becda894 ("gpiolib: export descriptor-based GPIO interface")
> and
>   14e85c0e69d5 ("gpio: remove gpio_descs global array")
> the "Interacting With the Legacy GPIO Subsystem" of GPIO consumer
> interface is correct.
>
> But is it the case afterwards?
>
> Details of the question are here [1].
>
> [1]: https://stackoverflow.com/q/64455505/2511795

I don't know if I even understand the question right, but gpio_to_desc()
can be called at any time as long as there is a struct gpio_chip with
the global GPIO number assigned to it. It will just index into the
array of descriptors stored inside the chip and return a pointer.
The allocation of the memory lives with the struct gpio_chip.

If for example that chip is on USB and you unplug that USB
cable, naturally referencing the descriptor after that point
will cause disasters.

The gpio_request()/free() doesn't really allocate or free
any memory at all. This is why we call gpio_to_desc() first
thing in the legacy functions.

Yours,
Linus Walleij



[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