linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/5] New descriptor-based GPIO interface
@ 2013-09-04 11:29 Alexandre Courbot
  2013-09-04 11:29 ` [RFC 1/5] gpiolib: factorize gpiod_get/set functions Alexandre Courbot
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Alexandre Courbot @ 2013-09-04 11:29 UTC (permalink / raw)
  To: Linus Walleij, Arnd Bergmann, Grant Likely, Thierry Reding,
	Stephen Warren
  Cc: gnurou, linux-gpio, linux-doc, linux-kernel, linux-arch,
	devicetree, Alexandre Courbot

Here is a first RFC for the new GPIO interface. It's terribly overdue, and in
order to avoid delaying it further I decided to send it as-is instead of being
even more perfectionist. The main issue I have with it is that it highlights
some points that could be simplified in gpiolib, some of which require a
refactoring of gpiolib's clients. I wasn't sure which, of the cleanup or new
interface, should come first and stayed in this state of confusion for several
months ; but in the end I believe it's more appropriate to clearly lay the
interfaces we want to use first, and then refactor the lib accordingly. So
please be mindful that another round of cleanup, both of gpiolib itself and its
consumers, should come once a later version of these patches is validated (and
hopefully merged) and that this series should be considered just another step
towards gpiolib's sanitization (although I also secretly hope the new interface
will be deemed useful by itself).

Another point that definitely needs more attention is the documentation. I am
not sure whether the new interface should be described as a couple of sections
in the existing GPIO documentation (the current approach) or as a new
documentation file of its own.

The new gpiod public interface is just an export of how gpiolib now works
internally. By representing GPIOs as opaque descriptors intead of integers, it
aims at making GPIO usage safer and more coherent with respect to other
subsystems by using a proper get/put mechanism and ensuring all GPIOs in use at
a given time are valid. It also makes GPIO acquisition easier for consumers, by
offering a standard way to bind GPIOs to devices. Finally, it tries to fix some
of the inconsistencies gpiolib acquired over time, like the incoherent handling
of active low GPIOs which was only valid when using the sysfs interface.

The old GPIO interface is still accessible and works the same way as before ; I
do not expect any existing code to break as a result of applying this series
(which is not extensively tested yet BTW).

TODO (preferably once this batch is validated):
- Change gpio_get()'s behavior to allow it to return specifiers other than the
first one for DT-declared GPIOs?
- Update as many users of the legacy interface as possible to use the new
interface
- Simplify gpiolib by removing redundant code and corner-cases (gpio_request
must die)
- Try to implement the GPIO fast-path method with gpiod, maybe using the LSB of
GPIO descriptors as a marker to forge fake descriptors?
- If possible, completely deprecate and remove the old gpio interface

Alexandre Courbot (5):
  gpiolib: factorize gpiod_get/set functions
  gpiolib: export descriptor-based GPIO interface
  gpiolib: port of_ functions to use gpiod
  gpiolib: add gpiod_get() and gpiod_put() functions
  gpiolib: update documentation

 Documentation/gpio.txt        | 119 ++++++++++
 drivers/gpio/gpiolib-of.c     |  28 ++-
 drivers/gpio/gpiolib.c        | 525 ++++++++++++++++++++++++++----------------
 include/asm-generic/gpio.h    | 227 ++++++------------
 include/linux/gpio.h          |  11 +-
 include/linux/gpio/consumer.h | 201 ++++++++++++++++
 include/linux/gpio/driver.h   | 163 +++++++++++++
 include/linux/of_gpio.h       |  29 ++-
 8 files changed, 920 insertions(+), 383 deletions(-)
 create mode 100644 include/linux/gpio/consumer.h
 create mode 100644 include/linux/gpio/driver.h

-- 
1.8.4


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2013-09-23 10:16 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-04 11:29 [RFC 0/5] New descriptor-based GPIO interface Alexandre Courbot
2013-09-04 11:29 ` [RFC 1/5] gpiolib: factorize gpiod_get/set functions Alexandre Courbot
2013-09-20  8:36   ` Linus Walleij
2013-09-21 12:39     ` Alexandre Courbot
2013-09-04 11:29 ` [RFC 2/5] gpiolib: export descriptor-based GPIO interface Alexandre Courbot
2013-09-04 19:58   ` Stephen Warren
2013-09-05  3:45     ` Alexandre Courbot
2013-09-04 11:29 ` [RFC 3/5] gpiolib: port of_ functions to use gpiod Alexandre Courbot
2013-09-04 11:29 ` [RFC 4/5] gpiolib: add gpiod_get() and gpiod_put() functions Alexandre Courbot
2013-09-04 19:56   ` Stephen Warren
2013-09-05  3:44     ` Alexandre Courbot
2013-09-11 13:57       ` Thierry Reding
2013-09-20 18:40     ` Linus Walleij
2013-09-23  9:31       ` Mika Westerberg
2013-09-04 11:29 ` [RFC 5/5] gpiolib: update documentation Alexandre Courbot
2013-09-20 17:59   ` Linus Walleij
2013-09-20  8:28 ` [RFC 0/5] New descriptor-based GPIO interface Linus Walleij
2013-09-20 18:06 ` Linus Walleij
2013-09-20 19:32   ` Thierry Reding
2013-09-20 21:23     ` Linus Walleij
2013-09-21 12:32       ` Alexandre Courbot
2013-09-23 10:21   ` Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).