From: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
To: Jamey Hicks <jamey.hicks@hp.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: gpio api
Date: Fri, 18 Feb 2005 15:35:17 +0100 [thread overview]
Message-ID: <20050218143517.GA5307@wohnheim.fh-wedel.de> (raw)
In-Reply-To: <4215F1A0.1030805@hp.com>
On Fri, 18 February 2005 08:46:08 -0500, Jamey Hicks wrote:
>
> GPIO Client Driver API
>
> The first two calls are analogous to request_irq/free_irq, so that
> driver can ensure that they have exclusive access to a GPIO and can
> specify asynchronous or synchronous access. I have run into problems
> due to out-of-date or misconfigured drivers that would be prevented by
> the use of these calls.
>
> #define GPIOF_SYNC (1 << 0)
> #define GPIOF_ASYNC (1 << 1)
> #define GPIOF_SYSFS (1 << 2)
> #define GPIOF_VALID (1 << 3)
>
> int request_gpio(int gpio_num, const char *name,
> void (*callback)(int gpionum, void *devid), int flags, void *devid);
> void free_gpio(int gpio_num, void *devid);
>
> It is a BUG to supply a NULL callback if GPIO is successfully
> requested with GPIOF_ASYNCH set. [Alternatively, split into sync and
> async calls and consider it a BUG to use the synchronous calls on a
> GPIO requested with GPIOF_ASYNC set.]
Don't split the interface. BUG_ON((flags&GPIOF_ASYNC) && !callback)
might be a good idea, but most likely there are valid reasons for NULL
callbacks as well.
Also, it's not unusual to request several pins at one. If the
requester can simply provide a bitmask, the calling code is *much*
simpler.
> int set_gpio_mode(int gpionum, int modeflags);
> int set_gpio_value(int gpionum, int value);
> int get_gpio_value(int gpionum);
These functions either lack a struct gpiochip argument or could be
omitted completely.
> GPIO Provider API
>
> struct gpiochip {
> int (*set)(struct gpiochip *chip, void *context, int value);
> int (*get)(struct gpiochip *chip void *context);
> int (*mode)(struct gpiochip *chip, void *context, int modeflags);
> };
A private structure is surely needed, no?
Overall, I like the idea. Having a standard interface for gpio
drivers makes life somewhat easier when writing a driver, and a *lot*
easier when using one. With every driver having their own custom
interface, some *will* end up broken and unusable.
Jörn
--
He that composes himself is wiser than he that composes a book.
-- B. Franklin
next prev parent reply other threads:[~2005-02-18 14:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-18 13:46 Jamey Hicks
2005-02-18 14:35 ` Jörn Engel [this message]
2005-02-21 10:02 ` Asier Llano Palacios
2005-02-21 10:18 ` Russell King
2005-02-22 2:18 ` Yoichi Yuasa
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=20050218143517.GA5307@wohnheim.fh-wedel.de \
--to=joern@wohnheim.fh-wedel.de \
--cc=jamey.hicks@hp.com \
--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
all inboxes | Powered by JetHome®