[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <6787cce8528c344c496724509762b2a11dea4bfb.1267225701.git.gardner.ben@gmail.com>
Date: Fri, 26 Feb 2010 17:26:25 -0600
From: Ben Gardner <gardner.ben@...il.com>
To: linux-kernel@...r.kernel.org,
Andres Salomon <dilinger@...labora.co.uk>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Ben Gardner <gardner.ben@...il.com>,
Andres Salomon <dilinger@...labora.co.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
David Brownell <dbrownell@...rs.sourceforge.net>,
Jani Nikula <ext-jani.1.nikula@...ia.com>
Subject: [PATCH 2/3] cs5535-gpio: Use set_direction
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@...il.com>
CC: Andres Salomon <dilinger@...labora.co.uk>
CC: Andrew Morton <akpm@...ux-foundation.org>
CC: David Brownell <dbrownell@...rs.sourceforge.net>
CC: Jani Nikula <ext-jani.1.nikula@...ia.com>
---
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists