2012-02-24 10:54:00

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH] gpio/gpio-stmpe: Fix the value returned by _get_value routine

From: Bhupesh Sharma <[email protected]>

The present _get_value routine returns the contents of the GPIO
Monitor Pin Status Register(GPMR) starting from the bit whose value
is requested to BIT 0.

For e.g. if we request the value of GPIO 6 in the earlier
implementation the value returned is:

BIT6 to BIT0

whereas it should just return BIT6.

This patch addresses the same.

Signed-off-by: Bhupesh Sharma <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
---
drivers/gpio/gpio-stmpe.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 094c5c4..dce3472 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -54,7 +54,7 @@ static int stmpe_gpio_get(struct gpio_chip *chip, unsigned offset)
if (ret < 0)
return ret;

- return ret & mask;
+ return !!(ret & mask);
}

static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
--
1.7.8.110.g4cb5d


2012-02-24 14:16:14

by Rabin Vincent

[permalink] [raw]
Subject: Re: [PATCH] gpio/gpio-stmpe: Fix the value returned by _get_value routine

On Fri, Feb 24, 2012 at 16:04, Viresh Kumar <[email protected]> wrote:
> The present _get_value routine returns the contents of the GPIO
> Monitor Pin Status Register(GPMR) starting from the bit whose value
> is requested to BIT 0.
>
> For e.g. if we request the value of GPIO 6 in the earlier
> implementation the value returned is:
>
> ? ? ? ?BIT6 to BIT0
>
> whereas it should just return BIT6.

The current implementation just returns (ret & mask) where mask
would have only BIT6 set, so how can it return "BIT6 to BIT0" ?

2012-02-24 14:42:54

by Rabin Vincent

[permalink] [raw]
Subject: Re: [PATCH] gpio/gpio-stmpe: Fix the value returned by _get_value routine

On Fri, Feb 24, 2012 at 19:59, viresh kumar <[email protected]> wrote:
> On Feb 24, 2012 7:46 PM, "Rabin Vincent" <[email protected]> wrote:
>> On Fri, Feb 24, 2012 at 16:04, Viresh Kumar <[email protected]> wrote:
>> > The present _get_value routine returns the contents of the GPIO
>> > Monitor Pin Status Register(GPMR) starting from the bit whose value
>> > is requested to BIT 0.
>> >
>> > For e.g. if we request the value of GPIO 6 in the earlier
>> > implementation the value returned is:
>> >
>> > ? ? ? ?BIT6 to BIT0
>> >
>> > whereas it should just return BIT6.
>>
>> The current implementation just returns (ret & mask) where mask
>> would have only BIT6 set, so how can it return "BIT6 to BIT0" ?
>
> Oops! I gave same comment when i saw this patch
> on our internal list and i forgot to fix log while applying.
>
> It actually returns 0b1000000 for example. And we need 1 here.

According to the documentation, gpio_get_value() (i.e. this function)
can return zero or non-zero, not necessarily zero or one.

2012-02-27 05:50:15

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH Resend] gpio/gpio-stmpe: Fix the value returned by _get_value routine

From: Bhupesh Sharma <[email protected]>

The present _get_value routine returns the contents of the GPIO Monitor Pin
Status Register(GPMR) starting from the bit whose value is requested to BIT 0
(irrelevant bits are replace by 0).

For e.g. if we request the value of GPIO 6 in the earlier implementation the
value returned is:

BIT6 followed by 6 0's

whereas it should just return BIT6.

This patch addresses the same.

Signed-off-by: Bhupesh Sharma <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
---
Changes in Resend: Commit log fixed

drivers/gpio/gpio-stmpe.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 094c5c4..dce3472 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -54,7 +54,7 @@ static int stmpe_gpio_get(struct gpio_chip *chip, unsigned offset)
if (ret < 0)
return ret;

- return ret & mask;
+ return !!(ret & mask);
}

static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
--
1.7.8.110.g4cb5d