All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Linus Walleij <linus.walleij@linaro.org>,
	Stephen Warren <swarren@wwwdotorg.org>
Cc: Alex Courbot <acourbot@nvidia.com>,
	devicetree-discuss@lists.ozlabs.org,
	linux-kernel@vger.kernel.org
Subject: Re: How about a gpio_get(device *, char *) function?
Date: Mon, 26 Nov 2012 11:14:31 +0000	[thread overview]
Message-ID: <20121126111431.AE4C23E09C2@localhost> (raw)
In-Reply-To: <CACRpkdaUJKs7zx=JWRUb+0Qz2dQU=R5KUK+CoM+nLCgHL99AFA@mail.gmail.com>

On Wed, 7 Nov 2012 22:28:01 +0100, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Mon, Nov 5, 2012 at 6:35 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> > [Me]
> >> gpio_get() should get an abstract handle just like clk_get() or
> >> regulator_get(), not a fixed numeral.
> >
> > I don't really see why the return type of gpio_get() influences whether
> > it can be implemented or not.
> 
> It doesn't influence that, but I want to follow the opaqueness design
> pattern from irq descriptors and struct clk.

Right. I like the pattern too. Unforutunately that means dealing with
somewhere on the order of 2500 callers of the old API. :-(

However, I don't think that the GPIO numberspace issue is completely
intertwined with opaqifying the gpio handles. The numberspace can be
fixed with the current API if someone creates a sparse gpio
registrations.

I don't have any problem with a gpio_get function, but I do agree that
making it return an opaque handle is how it should be written with a new
set of accessors. The handle should probably be simply the pointer to
the &gpio_desc[number] which is a private table in gpiolib.c. The
definition of it isn't available outside of gpiolib.c

In fact, the old functions should be redefined in terms of getting the
gpio_desc from the irq number and calling the new functions.

> 
> > With board files, some "gpio map" table would simply contain the same
> > int GPIO ID value the table as is used anywhere else already. With DT,
> > the same xlate function would translate from DT GPIO-chip-relative
> > IDs/specifiers into the global number space in the same way that we do
> > today via other APIs.
> 
> Yes, this part I buy into, just want to see how we can move forward
> from there. The coplete nightmare is to introduce something into DT
> that nails down a global GPIO numberspace... but I think that is not
> the case atleast.
> 
> > If the GPIO subsystem were reworked as you propose, this API could be
> > reworked in exactly the same way, or if implemented after the rework, it
> > would return whatever handle type was in use at the time.
> 
> Yes, I just think we should return an opaque struct from day 1, so
> just a little, little bit more to shield us.
> 
> Yours,
> Linus Walleij

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

  reply	other threads:[~2012-11-26 11:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31  9:04 How about a gpio_get(device *, char *) function? Alex Courbot
2012-10-31  9:04 ` Alex Courbot
2012-10-31 15:25 ` Stephen Warren
     [not found]   ` <509142F5.4010307-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-11-01  2:48     ` Alex Courbot
2012-11-01  2:48       ` Alex Courbot
2012-11-04 18:04 ` Linus Walleij
2012-11-05  7:31   ` Alex Courbot
2012-11-05 12:09     ` Linus Walleij
2012-11-26 11:25       ` Grant Likely
2012-11-05 17:35   ` Stephen Warren
2012-11-06  1:33     ` Alex Courbot
2012-11-07 21:24       ` Linus Walleij
2012-11-08  6:14         ` Alex Courbot
     [not found]         ` <CACRpkdYqCQc0Er1JR_eVzZPCycvKjd0Pph8Dcay0FbU3Q64D8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-11-08  6:23           ` Alex Courbot
2012-11-08  6:23             ` Alex Courbot
2012-11-13 13:13             ` Linus Walleij
2012-11-07 21:28     ` Linus Walleij
2012-11-26 11:14       ` Grant Likely [this message]
2012-11-28  3:38         ` Alex Courbot
2012-11-29 17:34           ` Grant Likely
2012-12-01 18:41             ` Linus Walleij
2012-12-03 14:15               ` Grant Likely
2012-11-26 11:17 ` Grant Likely

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=20121126111431.AE4C23E09C2@localhost \
    --to=grant.likely@secretlab.ca \
    --cc=acourbot@nvidia.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swarren@wwwdotorg.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.