* [PATCH v2] gpio: zevio: Get correct gpio output value
@ 2014-04-07 23:59 Axel Lin
2014-04-10 17:56 ` Linus Walleij
2014-04-22 12:29 ` Linus Walleij
0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2014-04-07 23:59 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot; +Cc: Gerhard Sittig, Fabian Vogt, linux-gpio
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.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/gpio/gpio-zevio.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-zevio.c b/drivers/gpio/gpio-zevio.c
index 9bf5034..29b0150 100644
--- a/drivers/gpio/gpio-zevio.c
+++ b/drivers/gpio/gpio-zevio.c
@@ -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;
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] gpio: zevio: Get correct gpio output value
2014-04-07 23:59 [PATCH v2] gpio: zevio: Get correct gpio output value Axel Lin
@ 2014-04-10 17:56 ` Linus Walleij
2014-04-11 0:16 ` Axel Lin
2014-04-22 12:29 ` Linus Walleij
1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2014-04-10 17:56 UTC (permalink / raw)
To: Axel Lin
Cc: Alexandre Courbot, Gerhard Sittig, Fabian Vogt,
linux-gpio@vger.kernel.org
On Tue, Apr 8, 2014 at 1:59 AM, Axel Lin <axel.lin@ingics.com> wrote:
> 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.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Waiting for an ACK in this v2 version.
Should it be tagged for stable even?
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] gpio: zevio: Get correct gpio output value
2014-04-10 17:56 ` Linus Walleij
@ 2014-04-11 0:16 ` Axel Lin
0 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2014-04-11 0:16 UTC (permalink / raw)
To: Linus Walleij
Cc: Alexandre Courbot, Gerhard Sittig, Fabian Vogt,
linux-gpio@vger.kernel.org
2014-04-11 1:56 GMT+08:00 Linus Walleij <linus.walleij@linaro.org>:
> On Tue, Apr 8, 2014 at 1:59 AM, Axel Lin <axel.lin@ingics.com> wrote:
>
>> 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.
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] gpio: zevio: Get correct gpio output value
2014-04-07 23:59 [PATCH v2] gpio: zevio: Get correct gpio output value Axel Lin
2014-04-10 17:56 ` Linus Walleij
@ 2014-04-22 12:29 ` Linus Walleij
1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2014-04-22 12:29 UTC (permalink / raw)
To: Axel Lin
Cc: Alexandre Courbot, Gerhard Sittig, Fabian Vogt,
linux-gpio@vger.kernel.org
On Tue, Apr 8, 2014 at 1:59 AM, Axel Lin <axel.lin@ingics.com> wrote:
> 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.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
OK out of patience waiting for ACKs, v2 patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-22 12:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-07 23:59 [PATCH v2] gpio: zevio: Get correct gpio output value Axel Lin
2014-04-10 17:56 ` Linus Walleij
2014-04-11 0:16 ` Axel Lin
2014-04-22 12:29 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).