linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] gpiolib: introduce descriptor-based GPIO interface
@ 2012-12-06  7:45 Alexandre Courbot
  2012-12-06  7:45 ` Alexandre Courbot
  0 siblings, 1 reply; 10+ messages in thread
From: Alexandre Courbot @ 2012-12-06  7:45 UTC (permalink / raw)
  To: Grant Likely, Linus Walleij, Arnd Bergmann
  Cc: linux-kernel, linux-arch, linux-arm-kernel, gnurou, Alexandre Courbot

Just a RFC to check if the direction seems good before going onward with more
serious work. This patch introduces a set of gpiod_* functions that work like
their gpio_* counterparts, but use opaque descriptors instead of integers.

The current integer-based GPIO namespace is bad because it allows GPIOs to be
used without being properly allocated, and poses portability concerns with the
maximum number of GPIOs of the system being a compile-time constant. Some
implementation details could also be improved by an opaque handler, e.g. the
GPIO descriptors could be moved from the current static array to a more flexible
list of GPIO chips containing their own descriptors.

With this patch GPIO handles can only be obtained by calling gpio_to_desc(),
which converts a valid GPIO number to its descriptor - proper lookup functions
that totally get rid of GPIO numbers are the next step if this first patch is
received positively.

This is only a first step towards a bigger gpiolib rework. Getting rid of the
integer handles for GPIOs will allow us to continue on with the following:
* Proper GPIO lookup functions a la regulator, pwm, etc.
* Getting rid of ARCH_NR_GPIO,
* Tearing out asm-generic/gpio.h into consumer/driver include files,
* ...

This API is only available if gpiolib is compiled in. One could however easily
implement a set of gpiod_* functions that would wrap around the old interface if
that was deemed necessary.

Comments and thoughts on potential issues are welcome, at this stage it is very
possible that I missed a few issues that will arise in later stages of this
project.

Alexandre Courbot (1):
  gpiolib: introduce descriptor-based GPIO interface

 drivers/gpio/gpiolib.c        | 302 ++++++++++++++++++++++--------------------
 include/asm-generic/gpio.h    |  74 ++++++++---
 include/linux/gpio/consumer.h |  45 +++++++
 3 files changed, 261 insertions(+), 160 deletions(-)
 create mode 100644 include/linux/gpio/consumer.h

-- 
1.8.0.1


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

end of thread, other threads:[~2012-12-10 22:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-06  7:45 [RFC] gpiolib: introduce descriptor-based GPIO interface Alexandre Courbot
2012-12-06  7:45 ` Alexandre Courbot
2012-12-06 14:42   ` Grant Likely
2012-12-07  2:06     ` Alex Courbot
2012-12-07  8:24       ` Linus Walleij
2012-12-10 22:34       ` Grant Likely
2012-12-06 20:19   ` Linus Walleij
2012-12-07  2:49   ` Guenter Roeck
2012-12-07  7:02     ` Alex Courbot
2012-12-07 15:07       ` Guenter Roeck

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