From: David Brownell <david-b@pacbell.net>
To: Ben Nizette <bn@niasdigital.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
dsilvers@simtec.co.uk
Subject: Re: [PATCH v2] GPIO: Add gpio_lookup
Date: Tue, 13 Oct 2009 15:05:44 -0700 [thread overview]
Message-ID: <200910131505.44739.david-b@pacbell.net> (raw)
In-Reply-To: <1255327904.5347.79.camel@ben-desktop>
On Sunday 11 October 2009, Ben Nizette wrote:
> OK for something supposedly basic, all this gpio stuff is getting messy.
Sigh. :(
One can only _expect_ that as infrastructure gets more widely
used, it (unfortunately) starts expanding. And one _hopes_ the
growth does not turn into bloat. This is a constant battle with
all tools and infrastructure.
> The gpio framework was written to use gpio numbers as they were
> recognised as being common to all possible implementations of the
> framework.
I'm not sure I'd put it that way. Most SoC-integrated GPIOs
had vendor docs using names like "GPIO-n"; a few combined them
with bank IDs, like "Port C-19". In all cases, the IDs could
be mapped to numbers ... ('C' - 'A') * 32 + 19, etc. And mostly
they *needed* to have such a mapping, since GPIOs are often the
main flavor of external IRQ signal, and IRQs are numbered.
Embedded boards also use pcf8574 I2C GPIO expanders and such,
which can be modeled as just fancier banks where IO the calls
require sleeping access. Enter gpiolib to pull such devices
into the API.
Plus of course, numbers are easily used as a global ID space,
on any platform. Trivially, if one had a per-GPIO structure
(a thing to avoid, in general, for a single hardware bit!!),
the pointer to that structure is a number. QED.
Originally, the only name-ish thing was labels for diagnostics,
to help associate for example GPIO-78 with nCS2 or SDA in the
/sys/kernel/debug/gpio listing or in diagnostics.
> I didn't notice Daniel's original patch fly by otherwise I would have
> said something at the time, but storing the names at the chip level
> seems an odd idea. Given that at that stage they were only for sysfs
> id, why not just give them as an argument to gpio_export()?
Yeah, I wasn't wholly keen on that either. Notice that we now
have gpio_export_link()... and that the names given in gpio bank
registration can conflict with the *existing* ones registered by
the gpio_request() primitives.
There's also some role conflict here ... the entity registering
the GPIO bank may not always know the purpose to which the GPIO
will be put, while the entity calling gpio_request() *does*. And
what good is a name which presents the wrong purpose?
Plus, GPIOs may need to be registered very early -- preceding
core_initcall() in some cases -- which can be a long time before
the board-specific labels are available, e.g. in arch_initcall().
But the biggest issue is name uniqueness ...
- Dave
next prev parent reply other threads:[~2009-10-13 22:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-10 19:48 [PATCH] GPIO: Add gpio_lookup Jonathan Corbet
2009-10-10 19:53 ` [PATCH v2] " Jonathan Corbet
2009-10-12 6:11 ` Ben Nizette
2009-10-12 15:23 ` Jonathan Corbet
2009-10-13 8:31 ` Ben Nizette
2009-10-13 22:13 ` David Brownell
2009-10-13 22:06 ` David Brownell
2009-10-13 22:05 ` David Brownell [this message]
2009-10-13 21:10 ` David Brownell
2009-10-13 22:28 ` Jonathan Corbet
2009-10-13 22:53 ` David Brownell
2009-10-14 12:53 ` Mark Brown
2009-10-13 18:05 ` [PATCH] " Andrew Morton
2009-10-13 18:19 ` Jonathan Corbet
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=200910131505.44739.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=akpm@linux-foundation.org \
--cc=bn@niasdigital.com \
--cc=corbet@lwn.net \
--cc=dsilvers@simtec.co.uk \
--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