linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio-pca953x: Fix read for chips with more than 8 gpios
@ 2013-08-14 14:20 Ricardo Ribalda Delgado
  2013-08-16 15:21 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Ricardo Ribalda Delgado @ 2013-08-14 14:20 UTC (permalink / raw)
  To: Linus Walleij, linux-gpio, linux-kernel; +Cc: Ricardo Ribalda Delgado

pca953x_read_single returns ONLY the value of the 8 inputs of the
same bank.

off can have a value from 0 to 15, therefore we have to find the
offset of that gpio within that bank.

Without this patch gpios 8-15 will always be read as zero.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/gpio/gpio-pca953x.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 426c51d..1a7ab13 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -308,7 +308,7 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off)
 		return 0;
 	}
 
-	return (reg_val & (1u << off)) ? 1 : 0;
+	return (reg_val & (1u << (off % BANK_SZ))) ? 1 : 0;
 }
 
 static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] gpio-pca953x: Fix read for chips with more than 8 gpios
@ 2013-08-14 21:29 Ricardo Ribalda Delgado
  0 siblings, 0 replies; 4+ messages in thread
From: Ricardo Ribalda Delgado @ 2013-08-14 21:29 UTC (permalink / raw)
  To: linux-gpio; +Cc: Ricardo Ribalda Delgado

pca953x_read_single returns ONLY the value of the 8 inputs of the
same bank.

off can have a value from 0 to 15, therefore we have to find the
offset of that gpio within that bank.

Without this patch gpios 8-15 will always be read as zero.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/gpio/gpio-pca953x.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 426c51d..1a7ab13 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -308,7 +308,7 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off)
 		return 0;
 	}
 
-	return (reg_val & (1u << off)) ? 1 : 0;
+	return (reg_val & (1u << (off % BANK_SZ))) ? 1 : 0;
 }
 
 static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio-pca953x: Fix read for chips with more than 8 gpios
  2013-08-14 14:20 [PATCH] gpio-pca953x: Fix read for chips with more than 8 gpios Ricardo Ribalda Delgado
@ 2013-08-16 15:21 ` Linus Walleij
  2013-08-16 16:29   ` Ricardo Ribalda Delgado
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2013-08-16 15:21 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado
  Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Ruder, Gregory CLEMENT

On Wed, Aug 14, 2013 at 4:20 PM, Ricardo Ribalda Delgado
<ricardo.ribalda@gmail.com> wrote:

> pca953x_read_single returns ONLY the value of the 8 inputs of the
> same bank.
>
> off can have a value from 0 to 15, therefore we have to find the
> offset of that gpio within that bank.
>
> Without this patch gpios 8-15 will always be read as zero.
>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>

Nice! But it turns out I already had an identical patch by
Andrew Ruder acked by Gregory Clement in my patch queue.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio-pca953x: Fix read for chips with more than 8 gpios
  2013-08-16 15:21 ` Linus Walleij
@ 2013-08-16 16:29   ` Ricardo Ribalda Delgado
  0 siblings, 0 replies; 4+ messages in thread
From: Ricardo Ribalda Delgado @ 2013-08-16 16:29 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Ruder, Gregory CLEMENT

Hello Linus

I tried to google it when I sent it, but I didnt found anything. Glad
to hear it is alreay in the queue :)

Regards!

On Fri, Aug 16, 2013 at 5:21 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Aug 14, 2013 at 4:20 PM, Ricardo Ribalda Delgado
> <ricardo.ribalda@gmail.com> wrote:
>
>> pca953x_read_single returns ONLY the value of the 8 inputs of the
>> same bank.
>>
>> off can have a value from 0 to 15, therefore we have to find the
>> offset of that gpio within that bank.
>>
>> Without this patch gpios 8-15 will always be read as zero.
>>
>> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
>
> Nice! But it turns out I already had an identical patch by
> Andrew Ruder acked by Gregory Clement in my patch queue.
>
> Yours,
> Linus Walleij



-- 
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-16 16:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-14 14:20 [PATCH] gpio-pca953x: Fix read for chips with more than 8 gpios Ricardo Ribalda Delgado
2013-08-16 15:21 ` Linus Walleij
2013-08-16 16:29   ` Ricardo Ribalda Delgado
  -- strict thread matches above, loose matches on Subject: below --
2013-08-14 21:29 Ricardo Ribalda Delgado

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).