* [PATCH] gpio: generic: clamp values from bgpio_get_set()
@ 2015-12-11 21:36 Linus Walleij
2015-12-11 21:47 ` Fabio Estevam
0 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2015-12-11 21:36 UTC (permalink / raw)
To: linux-gpio, Alexandre Courbot; +Cc: Linus Walleij, kernel, Vladimir Zapolskiy
The bgpio_get_set() call should return a value clamped to [0,1],
the current code will return a negative value if reading
bit 31, which turns the value negative as this is a signed value
and thus gets interpreted as an error by the gpiolib core.
Found on the gpio-mxc but applies to any MMIO driver.
Fixes: b19e7f51a55f "gpio: gpio-generic: add flag to read out output value from reg_set"
Cc: kernel@pengutronix.de
Cc: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Reported-by: Clemens Gruber <clemens.gruber@pqgruber.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpio-generic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index 72088028d7a9..ea581dc23d44 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -141,9 +141,9 @@ static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio)
unsigned long pinmask = bgc->pin2mask(bgc, gpio);
if (bgc->dir & pinmask)
- return bgc->read_reg(bgc->reg_set) & pinmask;
+ return !!(bgc->read_reg(bgc->reg_set) & pinmask);
else
- return bgc->read_reg(bgc->reg_dat) & pinmask;
+ return !!(bgc->read_reg(bgc->reg_dat) & pinmask);
}
static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
--
2.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: generic: clamp values from bgpio_get_set()
2015-12-11 21:36 [PATCH] gpio: generic: clamp values from bgpio_get_set() Linus Walleij
@ 2015-12-11 21:47 ` Fabio Estevam
2015-12-11 22:10 ` Linus Walleij
2015-12-17 13:49 ` Vladimir Zapolskiy
0 siblings, 2 replies; 9+ messages in thread
From: Fabio Estevam @ 2015-12-11 21:47 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Sascha Hauer,
Vladimir Zapolskiy
Hi Linus,
On Fri, Dec 11, 2015 at 7:36 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> The bgpio_get_set() call should return a value clamped to [0,1],
> the current code will return a negative value if reading
> bit 31, which turns the value negative as this is a signed value
> and thus gets interpreted as an error by the gpiolib core.
> Found on the gpio-mxc but applies to any MMIO driver.
>
> Fixes: b19e7f51a55f "gpio: gpio-generic: add flag to read out output value from reg_set"
This commit appeared in 4.2, so it would be nice to add a stable tag:
Cc: <stable@vger.kernel.org> # 4.2+
Regards,
Fabio Estevam
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: generic: clamp values from bgpio_get_set()
2015-12-11 21:47 ` Fabio Estevam
@ 2015-12-11 22:10 ` Linus Walleij
2015-12-11 22:23 ` Fabio Estevam
2015-12-17 13:49 ` Vladimir Zapolskiy
1 sibling, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2015-12-11 22:10 UTC (permalink / raw)
To: Fabio Estevam
Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Sascha Hauer,
Vladimir Zapolskiy
On Fri, Dec 11, 2015 at 10:47 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Fri, Dec 11, 2015 at 7:36 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
>> The bgpio_get_set() call should return a value clamped to [0,1],
>> the current code will return a negative value if reading
>> bit 31, which turns the value negative as this is a signed value
>> and thus gets interpreted as an error by the gpiolib core.
>> Found on the gpio-mxc but applies to any MMIO driver.
>>
>> Fixes: b19e7f51a55f "gpio: gpio-generic: add flag to read out output value from reg_set"
>
> This commit appeared in 4.2, so it would be nice to add a stable tag:
>
> Cc: <stable@vger.kernel.org> # 4.2+
IIUC Fixes: has exactly this effect: it will be applied to any kernel where
that commit is present. The beauty of git commit hashes.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: generic: clamp values from bgpio_get_set()
2015-12-11 22:10 ` Linus Walleij
@ 2015-12-11 22:23 ` Fabio Estevam
2015-12-15 8:37 ` Linus Walleij
0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2015-12-11 22:23 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Sascha Hauer,
Vladimir Zapolskiy
On Fri, Dec 11, 2015 at 8:10 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
>>> Fixes: b19e7f51a55f "gpio: gpio-generic: add flag to read out output value from reg_set"
>>
>> This commit appeared in 4.2, so it would be nice to add a stable tag:
>>
>> Cc: <stable@vger.kernel.org> # 4.2+
>
> IIUC Fixes: has exactly this effect: it will be applied to any kernel where
> that commit is present. The beauty of git commit hashes.
Not sure if this has the same effect as it is not mentioned at
Documentation/stable_kernel_rules.txt
Regards,
Fabio Estevam
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: generic: clamp values from bgpio_get_set()
2015-12-11 22:23 ` Fabio Estevam
@ 2015-12-15 8:37 ` Linus Walleij
2015-12-15 17:00 ` Greg KH
0 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2015-12-15 8:37 UTC (permalink / raw)
To: Fabio Estevam, Greg KH, linux-stable
Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Sascha Hauer,
Vladimir Zapolskiy
On Fri, Dec 11, 2015 at 11:23 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Fri, Dec 11, 2015 at 8:10 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
>
>>>> Fixes: b19e7f51a55f "gpio: gpio-generic: add flag to read out output value from reg_set"
>>>
>>> This commit appeared in 4.2, so it would be nice to add a stable tag:
>>>
>>> Cc: <stable@vger.kernel.org> # 4.2+
>>
>> IIUC Fixes: has exactly this effect: it will be applied to any kernel where
>> that commit is present. The beauty of git commit hashes.
>
> Not sure if this has the same effect as it is not mentioned at
> Documentation/stable_kernel_rules.txt
I have surely noticed it having that effect in practice, maybe it is time
to send a patch to that document.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: generic: clamp values from bgpio_get_set()
2015-12-15 8:37 ` Linus Walleij
@ 2015-12-15 17:00 ` Greg KH
2015-12-17 8:22 ` Linus Walleij
0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2015-12-15 17:00 UTC (permalink / raw)
To: Linus Walleij
Cc: Fabio Estevam, linux-stable, linux-gpio@vger.kernel.org,
Alexandre Courbot, Sascha Hauer, Vladimir Zapolskiy
On Tue, Dec 15, 2015 at 09:37:53AM +0100, Linus Walleij wrote:
> On Fri, Dec 11, 2015 at 11:23 PM, Fabio Estevam <festevam@gmail.com> wrote:
> > On Fri, Dec 11, 2015 at 8:10 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> >>>> Fixes: b19e7f51a55f "gpio: gpio-generic: add flag to read out output value from reg_set"
> >>>
> >>> This commit appeared in 4.2, so it would be nice to add a stable tag:
> >>>
> >>> Cc: <stable@vger.kernel.org> # 4.2+
> >>
> >> IIUC Fixes: has exactly this effect: it will be applied to any kernel where
> >> that commit is present. The beauty of git commit hashes.
> >
> > Not sure if this has the same effect as it is not mentioned at
> > Documentation/stable_kernel_rules.txt
>
> I have surely noticed it having that effect in practice, maybe it is time
> to send a patch to that document.
No, please don't. I do pick up _some_ patches that have "Fixes:" tags
in them, if they look relevant, and I'm bored at the moment. Otherwise,
if you want something in a stable release, put the needed
"stable@vger.kernel.org" tag in it, that way you know it will go there
as I know to look for that.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: generic: clamp values from bgpio_get_set()
2015-12-15 17:00 ` Greg KH
@ 2015-12-17 8:22 ` Linus Walleij
0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2015-12-17 8:22 UTC (permalink / raw)
To: Greg KH
Cc: Fabio Estevam, linux-stable, linux-gpio@vger.kernel.org,
Alexandre Courbot, Sascha Hauer, Vladimir Zapolskiy
On Tue, Dec 15, 2015 at 6:00 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> No, please don't. I do pick up _some_ patches that have "Fixes:" tags
> in them, if they look relevant, and I'm bored at the moment. Otherwise,
> if you want something in a stable release, put the needed
> "stable@vger.kernel.org" tag in it, that way you know it will go there
> as I know to look for that.
OK! I will be a better person from this day :D
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: generic: clamp values from bgpio_get_set()
2015-12-11 21:47 ` Fabio Estevam
2015-12-11 22:10 ` Linus Walleij
@ 2015-12-17 13:49 ` Vladimir Zapolskiy
2015-12-17 14:49 ` Linus Walleij
1 sibling, 1 reply; 9+ messages in thread
From: Vladimir Zapolskiy @ 2015-12-17 13:49 UTC (permalink / raw)
To: Fabio Estevam, Linus Walleij
Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Sascha Hauer,
Vladimir Zapolskiy, Greg Kroah-Hartman
On 11.12.2015 23:47, Fabio Estevam wrote:
> Hi Linus,
>
> On Fri, Dec 11, 2015 at 7:36 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
>> The bgpio_get_set() call should return a value clamped to [0,1],
>> the current code will return a negative value if reading
>> bit 31, which turns the value negative as this is a signed value
>> and thus gets interpreted as an error by the gpiolib core.
>> Found on the gpio-mxc but applies to any MMIO driver.
>>
>> Fixes: b19e7f51a55f "gpio: gpio-generic: add flag to read out output value from reg_set"
>
> This commit appeared in 4.2, so it would be nice to add a stable tag:
>
> Cc: <stable@vger.kernel.org> # 4.2+
As it was discussed yesterday in another thread, the specified commit is
correct, and v4.2 works good.
The problem is in commit e20538b82f1f ("gpio: Propagate errors from
chip->get()"), which is present in v4.3.
So, Fixes: tag should be removed or corrected IMHO.
--
With best wishes,
Vladimir
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: generic: clamp values from bgpio_get_set()
2015-12-17 13:49 ` Vladimir Zapolskiy
@ 2015-12-17 14:49 ` Linus Walleij
0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2015-12-17 14:49 UTC (permalink / raw)
To: Vladimir Zapolskiy
Cc: Fabio Estevam, linux-gpio@vger.kernel.org, Alexandre Courbot,
Sascha Hauer, Greg Kroah-Hartman
On Thu, Dec 17, 2015 at 2:49 PM, Vladimir Zapolskiy
<vladimir_zapolskiy@mentor.com> wrote:
> On 11.12.2015 23:47, Fabio Estevam wrote:
>> Hi Linus,
>>
>> On Fri, Dec 11, 2015 at 7:36 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
>>> The bgpio_get_set() call should return a value clamped to [0,1],
>>> the current code will return a negative value if reading
>>> bit 31, which turns the value negative as this is a signed value
>>> and thus gets interpreted as an error by the gpiolib core.
>>> Found on the gpio-mxc but applies to any MMIO driver.
>>>
>>> Fixes: b19e7f51a55f "gpio: gpio-generic: add flag to read out output value from reg_set"
>>
>> This commit appeared in 4.2, so it would be nice to add a stable tag:
>>
>> Cc: <stable@vger.kernel.org> # 4.2+
>
> As it was discussed yesterday in another thread, the specified commit is
> correct, and v4.2 works good.
>
> The problem is in commit e20538b82f1f ("gpio: Propagate errors from
> chip->get()"), which is present in v4.3.
>
> So, Fixes: tag should be removed or corrected IMHO.
OK fixed it, also tagged for stable # 4.3+
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-12-17 14:54 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-11 21:36 [PATCH] gpio: generic: clamp values from bgpio_get_set() Linus Walleij
2015-12-11 21:47 ` Fabio Estevam
2015-12-11 22:10 ` Linus Walleij
2015-12-11 22:23 ` Fabio Estevam
2015-12-15 8:37 ` Linus Walleij
2015-12-15 17:00 ` Greg KH
2015-12-17 8:22 ` Linus Walleij
2015-12-17 13:49 ` Vladimir Zapolskiy
2015-12-17 14:49 ` 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).