From: Alexandre Courbot <acourbot@nvidia.com>
To: Grant Likely <grant.likely@secretlab.ca>,
Linus Walleij <linus.walleij@linaro.org>,
Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, gnurou@gmail.com,
Alexandre Courbot <acourbot@nvidia.com>
Subject: [RFC] gpiolib: introduce descriptor-based GPIO interface
Date: Thu, 6 Dec 2012 16:45:17 +0900 [thread overview]
Message-ID: <1354779918-4028-1-git-send-email-acourbot@nvidia.com> (raw)
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
next reply other threads:[~2012-12-06 7:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-06 7:45 Alexandre Courbot [this message]
2012-12-06 7:45 ` [RFC] gpiolib: introduce descriptor-based GPIO interface Alexandre Courbot
2012-12-06 14:42 ` Grant Likely
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354779918-4028-1-git-send-email-acourbot@nvidia.com \
--to=acourbot@nvidia.com \
--cc=arnd@arndb.de \
--cc=gnurou@gmail.com \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@linaro.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).