diff options
author | Ben Gardner <gardner.ben@gmail.com> | 2010-03-05 16:44:38 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-06 14:26:48 -0500 |
commit | a8a5164c297c16c2f4be776714ca47dba252cc3d (patch) | |
tree | 03a3d1a4692d31a22a55cdce48c7edcf66394843 /drivers/gpio | |
parent | 89ea8bbe9c3eb2ea0cb57a4ecf283cab7326f0b0 (diff) |
gpio: cs5535-gpio: fix input direction
The cs5535-gpio driver's get() function was returning the output value.
This means that the GPIO pins would never work as an input, even if
configured as an input.
The driver should return the READ_BACK value, which is the sensed line
value. To make that work when the direction is 'output', INPUT_ENABLE
needs to be set.
In addition, the driver was not disabling OUTPUT_ENABLE when the direction
is set to 'input'. That would cause the GPIO to continue to drive the pin
if the direction was ever set to output.
This issue was noticed when attempting to use the gpiolib driver to read
an external input. I had previously been using the char/cs5535-gpio
driver.
Signed-off-by: Ben Gardner <gardner.ben@gmail.com>
Acked-by: Andres Salomon <dilinger@collabora.co.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: <stable@kernel.org> [2.6.33.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/cs5535-gpio.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c index 0fdbe94f24a3..0c3c498f2260 100644 --- a/drivers/gpio/cs5535-gpio.c +++ b/drivers/gpio/cs5535-gpio.c | |||
@@ -154,7 +154,7 @@ static int chip_gpio_request(struct gpio_chip *c, unsigned offset) | |||
154 | 154 | ||
155 | static int chip_gpio_get(struct gpio_chip *chip, unsigned offset) | 155 | static int chip_gpio_get(struct gpio_chip *chip, unsigned offset) |
156 | { | 156 | { |
157 | return cs5535_gpio_isset(offset, GPIO_OUTPUT_VAL); | 157 | return cs5535_gpio_isset(offset, GPIO_READ_BACK); |
158 | } | 158 | } |
159 | 159 | ||
160 | static void chip_gpio_set(struct gpio_chip *chip, unsigned offset, int val) | 160 | static void chip_gpio_set(struct gpio_chip *chip, unsigned offset, int val) |
@@ -172,6 +172,7 @@ static int chip_direction_input(struct gpio_chip *c, unsigned offset) | |||
172 | 172 | ||
173 | spin_lock_irqsave(&chip->lock, flags); | 173 | spin_lock_irqsave(&chip->lock, flags); |
174 | __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE); | 174 | __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE); |
175 | __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_ENABLE); | ||
175 | spin_unlock_irqrestore(&chip->lock, flags); | 176 | spin_unlock_irqrestore(&chip->lock, flags); |
176 | 177 | ||
177 | return 0; | 178 | return 0; |
@@ -184,6 +185,7 @@ static int chip_direction_output(struct gpio_chip *c, unsigned offset, int val) | |||
184 | 185 | ||
185 | spin_lock_irqsave(&chip->lock, flags); | 186 | spin_lock_irqsave(&chip->lock, flags); |
186 | 187 | ||
188 | __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE); | ||
187 | __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_ENABLE); | 189 | __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_ENABLE); |
188 | if (val) | 190 | if (val) |
189 | __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_VAL); | 191 | __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_VAL); |