gpio: zevio: Get correct gpio output value
PATCH v2 1/1 gpio: zevio: Get correct gpio output value
Read gpio output value from ZEVIO_GPIO_OUTPUT.
The spin_lock is required to ensure the direction is not changed before reading input/ouput value.
--- drivers/gpio/gpio-zevio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpio/gpio-zevio.c +8 -2
@@ -81,9 +81,15 @@ static inline void zevio_gpio_port_set(struct zevio_gpio *c, unsigned pin,static int zevio_gpio_get (struct gpio_chip *chip,unsigned pin) {struct zevio_gpio *controller =to_zevio_gpio (chip); +u32 val, dir; -/* Only reading allowed, so no spinlock needed */ -u32 val =zevio_gpio_port_get (controller, pin,ZEVIO_GPIO_INPUT ); +spin_lock (&controller->lock); + dir =zevio_gpio_port_get (controller, pin,ZEVIO_GPIO_DIRECTION ); +if (dir &BIT (ZEVIO_GPIO_BIT (pin))) + val =zevio_gpio_port_get (controller, pin,ZEVIO_GPIO_INPUT ); +else + val =zevio_gpio_port_get (controller, pin,ZEVIO_GPIO_OUTPUT ); +spin_unlock (&controller->lock);return (val >>ZEVIO_GPIO_BIT (pin)) &0x1 ; }
Signature · 1 line
1.8.3.2
Quoted 5 lines · Axel Lin
Read gpio output value from
ZEVIO_GPIO_OUTPUT.
Thespin_lockis required to ensure the direction is not changed before reading input/ouput value.Signed-off-by Axel Lin <[email protected]>
Waiting for an ACK in this v2 version.
Should it be tagged for stable even?
Yours,
Linus Walleij
2014-04-11 1:56 GMT+08:00 Linus Walleij <[email protected]>:
Quoted 11 lines · Axel Lin
Quoted 6 lines
Read gpio output value from
ZEVIO_GPIO_OUTPUT.
Thespin_lockis required to ensure the direction is not changed before reading input/ouput value.Signed-off-by Axel Lin <[email protected]>Waiting for an ACK in this v2 version.
Should it be tagged for stable even?
This is a new driver, so no need for stable.
Regards,
Axel
Quoted 5 lines · Axel Lin
Read gpio output value from
ZEVIO_GPIO_OUTPUT.
Thespin_lockis required to ensure the direction is not changed before reading input/ouput value.Signed-off-by Axel Lin <[email protected]>
OK out of patience waiting for ACKs, v2 patch applied.
Yours,
Linus Walleij