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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to