Re: [PATCH 1/3] gpiolib: add gpio_set_direction()

From: Andres Salomon
Date: Fri Feb 26 2010 - 18:40:23 EST


On Fri, 26 Feb 2010 17:26:24 -0600
Ben Gardner <gardner.ben@xxxxxxxxx> wrote:

> Combine gpio_direction_input() and gpio_direction_output() into
> gpio_set_direction().
> Add 'none' and 'inout' directions to the sysfs interface.
>
> Signed-off-by: Ben Gardner <gardner.ben@xxxxxxxxx>
> CC: Andres Salomon <dilinger@xxxxxxxxxxxxxxx>
> CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> CC: David Brownell <dbrownell@xxxxxxxxxxxxxxxxxxxxx>
> CC: Jani Nikula <ext-jani.1.nikula@xxxxxxxxx>
> ---
> drivers/gpio/gpiolib.c | 123 ++++++++++++++++++++++----------------------
> include/asm-generic/gpio.h | 6 ++
> include/linux/gpio.h | 5 ++
> 3 files changed, 73 insertions(+), 61 deletions(-)
>
[...]
> diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
> index 485eeb6..17c7642 100644
> --- a/include/asm-generic/gpio.h
> +++ b/include/asm-generic/gpio.h
> @@ -41,6 +41,8 @@ struct module;
> * enabling module power and clock; may sleep
> * @free: optional hook for chip-specific deactivation, such as
> * disabling module power and clock; may sleep
> + * @set_direction: configures signal "offset" as "direction" (0-3, bit0=input,
> + * bit1=output) or returns error


How about something like the following for set_direction, so we're not
comparing magic bits?

/* gpio direction flags */
#define GPIO_DIR_NONE 0
#define GPIO_DIR_INPUT (1 << 0)
#define GPIO_DIR_OUTPUT (1 << 1)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/