[PATCH 2/3] cs5535-gpio: Use set_direction

From: Ben Gardner
Date: Fri Feb 26 2010 - 18:26:58 EST


The CS5535 GPIO has independant controls for input and output enable.
Use the set_direction method instead of direction_input and direction_output
to enable use of the bidirectional mode.

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/cs5535-gpio.c | 34 +++++++++++++++-------------------
1 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c
index 0fdbe94..0cb1462 100644
--- a/drivers/gpio/cs5535-gpio.c
+++ b/drivers/gpio/cs5535-gpio.c
@@ -165,30 +165,27 @@ static void chip_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
cs5535_gpio_clear(offset, GPIO_OUTPUT_VAL);
}

-static int chip_direction_input(struct gpio_chip *c, unsigned offset)
-{
- struct cs5535_gpio_chip *chip = (struct cs5535_gpio_chip *) c;
- unsigned long flags;
-
- spin_lock_irqsave(&chip->lock, flags);
- __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE);
- spin_unlock_irqrestore(&chip->lock, flags);
-
- return 0;
-}
-
-static int chip_direction_output(struct gpio_chip *c, unsigned offset, int val)
+static int chip_set_direction(struct gpio_chip *c, unsigned offset,
+ int direction, int value)
{
struct cs5535_gpio_chip *chip = (struct cs5535_gpio_chip *) c;
unsigned long flags;

spin_lock_irqsave(&chip->lock, flags);

- __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_ENABLE);
- if (val)
- __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_VAL);
+ if (direction & 1)
+ __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE);
else
- __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_VAL);
+ __cs5535_gpio_clear(chip, offset, GPIO_INPUT_ENABLE);
+
+ if (direction & 2) {
+ if (value)
+ __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_VAL);
+ else
+ __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_VAL);
+ __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_ENABLE);
+ } else
+ __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_ENABLE);

spin_unlock_irqrestore(&chip->lock, flags);

@@ -219,8 +216,7 @@ static struct cs5535_gpio_chip cs5535_gpio_chip = {
.get = chip_gpio_get,
.set = chip_gpio_set,

- .direction_input = chip_direction_input,
- .direction_output = chip_direction_output,
+ .set_direction = chip_set_direction,
},
};

--
1.7.0

--
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/