Skip to contentSkip to conversation

kernel 3.14.28/gpiolib: Return GPIO logical value, not true value

PATCH In review Gary Thomas 4 participants 16 messages May 20, 2015 – Jun 17, 2015 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel 3.14.28/gpiolib: Return GPIO logical value, not true value

Previous versions of the kernel returned the logical value of GPIO signals (i.e. 0 or 1). This patch restores this behavior.

---
 drivers/gpio/gpiolib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib.c +1 -1
index 50c4922..45aa695 100644
@@ -376,7 +376,7 @@ static ssize_t gpio_value_show(struct device *dev,
 	if (!test_bit(FLAG_EXPORT, &desc->flags))
 		status = -EIO;
 	else
-		status = sprintf(buf, "%d\n", gpiod_get_value_cansleep(desc));
+		status = sprintf(buf, "%d\n", !!gpiod_get_value_cansleep(desc));
 
 	mutex_unlock(&sysfs_lock);
 	return status;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 4 lines · Gary Thomas

Previous versions of the kernel returned the logical value of GPIO signals (i.e. 0 or 1). This patch restores this behavior.

I am not sure this is a correct fix. I tried to find out the commit which changed the behaviour without success.

Fabio, is it possible for you to check how mainline is behaving? and more important does it need any fix?

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#2 lore raw
Quoted 4 lines · Otavio Salvador
Quoted 3 lines · Gary Thomas

Previous versions of the kernel returned the logical value of GPIO signals (i.e. 0 or 1). This patch restores this behavior.

Quoted 8 lines
Quoted 1 line

I am not sure this is a correct fix. I tried to find out the commit which changed the behaviour without success.

Fabio, is it possible for you to check how mainline is behaving? and more important does it need any fix?

If by mainline you mean 4.1+, the code is very different and looks much more like the 3.10 version than the FSL 3.14.

My change simply matches the behaviour (and indeed uses the same construct) as the 3.10 kernel.

Also, as long as I can recall, reading a GPIO pin has returned 0/1, except for a small period during 2.6 where it was broken and quickly repaired.

Signature · 4 lines
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
#3 lore raw
Quoted 20 lines · Gary Thomas
Quoted 6 lines · Otavio Salvador
Quoted 4 lines · Gary Thomas

Previous versions of the kernel returned the logical value of GPIO signals (i.e. 0 or 1). This patch restores this behavior.

Quoted 9 lines
Quoted 1 line

I am not sure this is a correct fix. I tried to find out the commit which changed the behaviour without success.

Fabio, is it possible for you to check how mainline is behaving? and more important does it need any fix?

If by mainline you mean 4.1+, the code is very different and looks much more like the 3.10 version than the FSL 3.14.

Quoted 6 lines

My change simply matches the behaviour (and indeed uses the same construct) as the 3.10 kernel.

Also, as long as I can recall, reading a GPIO pin has returned 0/1, except for a small period during 2.6 where it was broken and quickly repaired.

If there is a patch which fixes this upstream I would prefer to cherry-pick this one.

Do you know which change has restored the behaviour?

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#5 lore raw
In reply to Eric Bénard
Quoted 12 lines · Eric Bénard
Quoted 9 lines · Otavio Salvador
Quoted 4 lines · Gary Thomas

Previous versions of the kernel returned the logical value of GPIO signals (i.e. 0 or 1). This patch restores this behavior.

I am not sure this is a correct fix. I tried to find out the commit which changed the behaviour without success.

Quoted 6 lines
Quoted 3 lines

Fabio, is it possible for you to check how mainline is behaving? and more important does it need any fix?

fixed mainline by :
25b35da gpio: generic: clamp retured value to [0,1] which is not in 3.4.28

True enough, but this patch won't apply to 3.14.28 as the code is very different.

Signature · 4 lines
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
#6 lore raw
Quoted 2 lines · Gary Thomas

True enough, but this patch won't apply to 3.14.28 as the code is very different.

Yes, this commit appeared in 3.15.

I suggest we go with Gary's patch for 3.14.

#4 lore raw
In reply to Otavio Salvador
Quoted 4 lines · Otavio Salvador
Quoted 3 lines · Gary Thomas

Previous versions of the kernel returned the logical value of GPIO signals (i.e. 0 or 1). This patch restores this behavior.

Quoted 8 lines
Quoted 1 line

I am not sure this is a correct fix. I tried to find out the commit which changed the behaviour without success.

Fabio, is it possible for you to check how mainline is behaving? and more important does it need any fix?

fixed mainline by :
25b35da gpio: generic: clamp retured value to [0,1] which is not in 3.4.28

Eric

#8 lore raw
In reply to Eric Bénard
Quoted 8 lines · Eric Bénard

I think it should apply easily, as gpio-generic.c is very similar between 3.14.28 and mainline :

3.14.28
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/gpio/gpio-generic.c?h=linux-3.14.y&id=v3.14.28#n142

commit 25b35da :
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/gpio/gpio-generic.c?id=25b35da7f4cce82271859f1b6eabd9f3bd41a2bb

Yes, agreed. It is a one-line patch, so we can easily use the mainline fix.

#9 lore raw
Quoted 5 lines · Fabio Estevam
Quoted 3 lines · Eric Bénard

I think it should apply easily, as gpio-generic.c is very similar between 3.14.28 and mainline :

Quoted 8 lines
Quoted 5 lines

3.14.28
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/gpio/gpio-generic.c?h=linux-3.14.y&id=v3.14.28#n142

commit 25b35da :
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/gpio/gpio-generic.c?id=25b35da7f4cce82271859f1b6eabd9f3bd41a2bb

Yes, agreed. It is a one-line patch, so we can easily use the mainline fix.

I concur - my change was local to just the sysfs code, but this change is more correct (and already in mainline)

Signature · 4 lines
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
#15 lore raw
In reply to Fabio Estevam
Quoted 5 lines · Fabio Estevam
Quoted 3 lines · Eric Bénard

I think it should apply easily, as gpio-generic.c is very similar between 3.14.28 and mainline :

Quoted 7 lines
Quoted 5 lines

3.14.28
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/gpio/gpio-generic.c?h=linux-3.14.y&id=v3.14.28#n142

commit 25b35da :
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/gpio/gpio-generic.c?id=25b35da7f4cce82271859f1b6eabd9f3bd41a2bb

Yes, agreed. It is a one-line patch, so we can easily use the mainline fix.

Yes. It applies fine in 3.14.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#10 lore raw
In reply to Gary Thomas
Quoted 16 lines · Gary Thomas
Quoted 15 lines · Fabio Estevam
Quoted 10 lines · Eric Bénard

I think it should apply easily, as gpio-generic.c is very similar between 3.14.28 and mainline :

3.14.28

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/gpio/gpio-generic.c?h=linux-3.14.y&id=v3.14.28#n142

commit 25b35da :

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/gpio/gpio-generic.c?id=25b35da7f4cce82271859f1b6eabd9f3bd41a2bb

Quoted 6 lines
Quoted 3 lines

Yes, agreed. It is a one-line patch, so we can easily use the mainline fix.

I concur - my change was local to just the sysfs code, but this change is more correct (and already in mainline)

Can you generate a proper patch for it?

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#11 lore raw
Quoted 17 lines · Otavio Salvador
Quoted 16 lines · Gary Thomas
Quoted 15 lines · Fabio Estevam
Quoted 10 lines · Eric Bénard

I think it should apply easily, as gpio-generic.c is very similar between 3.14.28 and mainline :

3.14.28

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/gpio/gpio-generic.c?h=linux-3.14.y&id=v3.14.28#n142

commit 25b35da :

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/gpio/gpio-generic.c?id=25b35da7f4cce82271859f1b6eabd9f3bd41a2bb

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Yes, agreed. It is a one-line patch, so we can easily use the mainline fix.

I concur - my change was local to just the sysfs code, but this change is more correct (and already in mainline)

Can you generate a proper patch for it?

Why not just cherry-pick from 25b35da? It then has all of the proper signed-off-by, etc.

Signature · 4 lines
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
#12 lore raw
Quoted 32 lines · Gary Thomas
Quoted 31 lines · Otavio Salvador
Quoted 27 lines · Gary Thomas
Quoted 15 lines · Fabio Estevam
Quoted 11 lines · Eric Bénard

I think it should apply easily, as gpio-generic.c is very similar between 3.14.28 and mainline :

3.14.28

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/gpio/gpio-generic.c?h=linux-3.14.y&id=v3.14.28#n142

commit 25b35da :

Quoted 7 lines
Quoted 1 line

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/gpio/gpio-generic.c?id=25b35da7f4cce82271859f1b6eabd9f3bd41a2bb

Yes, agreed. It is a one-line patch, so we can easily use the mainline fix.

I concur - my change was local to just the sysfs code, but this change is more correct (and already in mainline)

Quoted 5 lines
Quoted 2 lines

Can you generate a proper patch for it?

Why not just cherry-pick from 25b35da? It then has all of the proper signed-off-by, etc.

I cannot push at git.freescale.com so this is a problem. For linux-fslc this is easy.

For now, I think a patch needs to be exported and applied on top of the original Git tree. Fabio, can you ask if 25b35da can be applied at Freescale's git?

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#13 lore raw
Quoted 9 lines · Otavio Salvador
Quoted 2 lines

Why not just cherry-pick from 25b35da? It then has all of the proper signed-off-by, etc.

I cannot push at git.freescale.com so this is a problem. For linux-fslc this is easy.

For now, I think a patch needs to be exported and applied on top of the original Git tree. Fabio, can you ask if 25b35da can be applied at Freescale's git?

Lauren,

Could you ask the BSP team to apply 25b35da commit from mainline into 3.14?

Thanks

#7 lore raw
In reply to Gary Thomas
Quoted 16 lines · Gary Thomas
Quoted 15 lines · Eric Bénard
Quoted 12 lines · Otavio Salvador
Quoted 4 lines · Gary Thomas

Previous versions of the kernel returned the logical value of GPIO signals (i.e. 0 or 1). This patch restores this behavior.

I am not sure this is a correct fix. I tried to find out the commit which changed the behaviour without success.

Fabio, is it possible for you to check how mainline is behaving? and more important does it need any fix?

Quoted 7 lines
Quoted 3 lines

fixed mainline by :
25b35da gpio: generic: clamp retured value to [0,1] which is not in 3.4.28

True enough, but this patch won't apply to 3.14.28 as the code is very different.

I think it should apply easily, as gpio-generic.c is very similar between 3.14.28 and mainline :

3.14.28
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/gpio/gpio-generic.c?h=linux-3.14.y&id=v3.14.28#n142

commit 25b35da :
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/gpio/gpio-generic.c?id=25b35da7f4cce82271859f1b6eabd9f3bd41a2bb

Eric

#14 lore raw
In reply to Fabio Estevam
Quoted 9 lines · Fabio Estevam
Quoted 6 lines · Otavio Salvador
Quoted 2 lines

Why not just cherry-pick from 25b35da? It then has all of the proper signed-off-by, etc.

I cannot push at git.freescale.com so this is a problem. For linux-fslc this is easy.

Quoted 7 lines
Quoted 3 lines

For now, I think a patch needs to be exported and applied on top of the original Git tree. Fabio, can you ask if 25b35da can be applied at Freescale's git?

Lauren,

Could you ask the BSP team to apply 25b35da commit from mainline into 3.14?

It is a shame but it has not been applied yet. I am cooking a forked kernel for bugfixes like this and will send a patch for testing very soon.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750