From: Linus Walleij <linus.walleij@linaro.org>
To: Alex Courbot <acourbot@nvidia.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>,
Grant Likely <grant.likely@secretlab.ca>,
"devicetree-discuss@lists.ozlabs.org"
<devicetree-discuss@lists.ozlabs.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: How about a gpio_get(device *, char *) function?
Date: Tue, 13 Nov 2012 14:13:45 +0100 [thread overview]
Message-ID: <CACRpkdZqAbRsvKEqTHNsZGsZO0KEMS1RyLtxujjdo8Xw59xnDA@mail.gmail.com> (raw)
In-Reply-To: <1503934.I4tc7K6I6s@percival>
On Thu, Nov 8, 2012 at 7:23 AM, Alex Courbot <acourbot@nvidia.com> wrote:
> On Thursday 08 November 2012 05:24:19 Linus Walleij wrote:
>> On Tue, Nov 6, 2012 at 2:33 AM, Alex Courbot <acourbot@nvidia.com> wrote:
>> > How about, in a first time (and because I'd also like to get the power
>> > seqs
>> > moving on), a typedef from int to gpio_handle_t and a first implementation
>> > of the gpio_handle_*() API that would just call the existing
>> > integer-based API (apart from gpio_handle_get())? That way things will
>> > not break when we switch to a real handle.
>>
>> I'm afraid of typedef:ing gpio_handle_t to int because it sort of
>> encourages non-handlers to be used mixed with the old integers.
>>
>> I would prefer to create, e.g. in <linux/gpio/consumer.h>
>> something like:
>>
>> struct gpio;
>>
>> struct gpio *gpio_get(struct device *dev, const char *name);
>>
>> int gpio_get_value(struct gpio *g);
>>
>> Nothing more! I.e. struct gpio is an opaque cookie, nothing to be known
>> about it.
>
> However these is already a struct gpio declared in linux/gpio.h. Shall the
> opaque handler be renamed something like "struct gpioh", or is your idea to
> make both APIs mutually exclusive?
Basically I'd like the API's to be mutually execlusive.
But maybe there is a namespace clash anyway, since the
handler code will have to #linclude <linux/gpio.h>
This is one of the rare cases where I'd maybe like to
even #undef gpio in the core code just to be able to
mask that defintion of "gpio" with the "gpio" from the
new API.
I really like the fact that it will bite your hand if you try
to use both APIs at once, you could even introduce some
#define DO_NOT_INCLUDE_LINUX_GPIO_H
in <linux/gpio/consumer.h>
And
#define DO_NOT_INCLUDE_GPIO_CONSUMER_H
in <linux/gpio.h>
and then put things like:
#ifdef DO_NOT_INCLUDE_LINUX_GPIO_H
#error "Trying to use mutually exclusive interfaces"
#endif
into <linux/gpio.h>...
Yours,
Linus Walleij
next prev parent reply other threads:[~2012-11-13 13:13 UTC|newest]
Thread overview: 20+ 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 15:25 ` Stephen Warren
[not found] ` <509142F5.4010307-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
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-13 13:13 ` Linus Walleij [this message]
2012-11-07 21:28 ` Linus Walleij
2012-11-26 11:14 ` Grant Likely
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=CACRpkdZqAbRsvKEqTHNsZGsZO0KEMS1RyLtxujjdo8Xw59xnDA@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=acourbot@nvidia.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=swarren@wwwdotorg.org \
--cc=tglx@linutronix.de \
/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).