* [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce()
@ 2013-09-03 10:39 Thierry Reding
2013-09-03 10:39 ` [PATCH 2/2] gpio: Use proper indentation Thierry Reding
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Thierry Reding @ 2013-09-03 10:39 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-kernel
Return an error if neither the ->set() nor the ->set_debounce() function
is implemented by the chip. Furthermore move locking further down so the
lock doesn't have to be unlocked on error. This is safe to do because at
this point the lock doesn't protect anything.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Linus,
Feel free to squash this into the commit that introduced these:
fc9bbfb: gpio: improve error path in gpiolib
Thierry
drivers/gpio/gpiolib.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index acd19c9..9f8a134 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1777,14 +1777,15 @@ static int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
return -EINVAL;
}
- spin_lock_irqsave(&gpio_lock, flags);
-
chip = desc->chip;
if (!chip->set || !chip->set_debounce) {
pr_warn("%s: missing set() or set_debounce() operations\n",
__func__);
+ return -EIO;
}
+ spin_lock_irqsave(&gpio_lock, flags);
+
status = gpio_ensure_requested(desc);
if (status < 0)
goto fail;
--
1.8.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] gpio: Use proper indentation
2013-09-03 10:39 [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce() Thierry Reding
@ 2013-09-03 10:39 ` Thierry Reding
2013-09-03 12:11 ` Linus Walleij
2013-09-03 12:10 ` [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce() Linus Walleij
2013-09-03 20:25 ` Stephen Warren
2 siblings, 1 reply; 8+ messages in thread
From: Thierry Reding @ 2013-09-03 10:39 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-kernel
Indentation should be done using tabs, not a combination of tabs and
spaces.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Linus,
Feel free to squash this into the commit that introduced these:
fc9bbfb: gpio: improve error path in gpiolib
Thierry
drivers/gpio/gpiolib.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 9f8a134..b762718 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1636,8 +1636,8 @@ static int gpiod_direction_input(struct gpio_desc *desc)
chip = desc->chip;
if (!chip->get || !chip->direction_input) {
- pr_warn("%s: missing get() or direction_input() operations\n",
- __func__);
+ pr_warn("%s: missing get() or direction_input() operations\n",
+ __func__);
return -EIO;
}
@@ -1709,8 +1709,8 @@ static int gpiod_direction_output(struct gpio_desc *desc, int value)
chip = desc->chip;
if (!chip->set || !chip->direction_output) {
- pr_warn("%s: missing set() or direction_output() operations\n",
- __func__);
+ pr_warn("%s: missing set() or direction_output() operations\n",
+ __func__);
return -EIO;
}
@@ -1779,8 +1779,8 @@ static int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
chip = desc->chip;
if (!chip->set || !chip->set_debounce) {
- pr_warn("%s: missing set() or set_debounce() operations\n",
- __func__);
+ pr_warn("%s: missing set() or set_debounce() operations\n",
+ __func__);
return -EIO;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce()
2013-09-03 10:39 [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce() Thierry Reding
2013-09-03 10:39 ` [PATCH 2/2] gpio: Use proper indentation Thierry Reding
@ 2013-09-03 12:10 ` Linus Walleij
2013-09-03 15:34 ` Kevin Hilman
2013-09-03 20:25 ` Stephen Warren
2 siblings, 1 reply; 8+ messages in thread
From: Linus Walleij @ 2013-09-03 12:10 UTC (permalink / raw)
To: Thierry Reding
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Frank Rowand
On Tue, Sep 3, 2013 at 12:39 PM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> Return an error if neither the ->set() nor the ->set_debounce() function
> is implemented by the chip. Furthermore move locking further down so the
> lock doesn't have to be unlocked on error. This is safe to do because at
> this point the lock doesn't protect anything.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> Linus,
>
> Feel free to squash this into the commit that introduced these:
>
> fc9bbfb: gpio: improve error path in gpiolib
Hm I fixed part of this bug yesterday, but screwed up and left the dangling
spinlock in there, what is wrong with me :-(
Anyway, fixed it _finally_ now, thanks to you.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] gpio: Use proper indentation
2013-09-03 10:39 ` [PATCH 2/2] gpio: Use proper indentation Thierry Reding
@ 2013-09-03 12:11 ` Linus Walleij
2013-09-03 12:23 ` Thierry Reding
0 siblings, 1 reply; 8+ messages in thread
From: Linus Walleij @ 2013-09-03 12:11 UTC (permalink / raw)
To: Thierry Reding; +Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
On Tue, Sep 3, 2013 at 12:39 PM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> Indentation should be done using tabs, not a combination of tabs and
> spaces.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> Linus,
>
> Feel free to squash this into the commit that introduced these:
>
> fc9bbfb: gpio: improve error path in gpiolib
This part I actually fixed up properly yesterday, but thanks anyway.
Thanks,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] gpio: Use proper indentation
2013-09-03 12:11 ` Linus Walleij
@ 2013-09-03 12:23 ` Thierry Reding
0 siblings, 0 replies; 8+ messages in thread
From: Thierry Reding @ 2013-09-03 12:23 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 656 bytes --]
On Tue, Sep 03, 2013 at 02:11:39PM +0200, Linus Walleij wrote:
> On Tue, Sep 3, 2013 at 12:39 PM, Thierry Reding
> <thierry.reding@gmail.com> wrote:
>
> > Indentation should be done using tabs, not a combination of tabs and
> > spaces.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> > Linus,
> >
> > Feel free to squash this into the commit that introduced these:
> >
> > fc9bbfb: gpio: improve error path in gpiolib
>
> This part I actually fixed up properly yesterday, but thanks anyway.
Yes you did. I was impatient and couldn't wait for today's linux-next to
show up. Sorry for the noise.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce()
2013-09-03 12:10 ` [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce() Linus Walleij
@ 2013-09-03 15:34 ` Kevin Hilman
0 siblings, 0 replies; 8+ messages in thread
From: Kevin Hilman @ 2013-09-03 15:34 UTC (permalink / raw)
To: Linus Walleij
Cc: Thierry Reding, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, Frank Rowand, Olof Johansson
[+Olof who had mentioned lock recursion BUG in -next]
On Tue, Sep 3, 2013 at 5:10 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Tue, Sep 3, 2013 at 12:39 PM, Thierry Reding
> <thierry.reding@gmail.com> wrote:
>
>> Return an error if neither the ->set() nor the ->set_debounce() function
>> is implemented by the chip. Furthermore move locking further down so the
>> lock doesn't have to be unlocked on error. This is safe to do because at
>> this point the lock doesn't protect anything.
>>
>> Signed-off-by: Thierry Reding <treding@nvidia.com>
>> ---
>> Linus,
>>
>> Feel free to squash this into the commit that introduced these:
>>
>> fc9bbfb: gpio: improve error path in gpiolib
>
> Hm I fixed part of this bug yesterday, but screwed up and left the dangling
> spinlock in there, what is wrong with me :-(
>
> Anyway, fixed it _finally_ now, thanks to you.
Exiting without unlocking was causing a lock recurision lockup in
next-20130903 on exynos5/arndale. I just verified that moving the
spinlock down as propsed here fixes the problem in -next.
Thanks,
Kevin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce()
2013-09-03 10:39 [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce() Thierry Reding
2013-09-03 10:39 ` [PATCH 2/2] gpio: Use proper indentation Thierry Reding
2013-09-03 12:10 ` [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce() Linus Walleij
@ 2013-09-03 20:25 ` Stephen Warren
2013-09-06 8:55 ` Linus Walleij
2 siblings, 1 reply; 8+ messages in thread
From: Stephen Warren @ 2013-09-03 20:25 UTC (permalink / raw)
To: Thierry Reding; +Cc: Linus Walleij, linux-gpio, linux-kernel
On 09/03/2013 04:39 AM, Thierry Reding wrote:
> Return an error if neither the ->set() nor the ->set_debounce() function
> is implemented by the chip. Furthermore move locking further down so the
> lock doesn't have to be unlocked on error. This is safe to do because at
> this point the lock doesn't protect anything.
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> chip = desc->chip;
> if (!chip->set || !chip->set_debounce) {
> pr_warn("%s: missing set() or set_debounce() operations\n",
> __func__);
> + return -EIO;
> }
BTW, I'm not sure that error-path should pr_warn(). For example, if this
error-patch is taken due to a call from
gpio_keys.c:gpio_keys_setup_key(), then a timer will be used for
debounce instead, which is all perfectly valid, and probably not
something that should be spewed to the kernel log.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce()
2013-09-03 20:25 ` Stephen Warren
@ 2013-09-06 8:55 ` Linus Walleij
0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2013-09-06 8:55 UTC (permalink / raw)
To: Stephen Warren
Cc: Thierry Reding, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
On Tue, Sep 3, 2013 at 10:25 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> chip = desc->chip;
>> if (!chip->set || !chip->set_debounce) {
>> pr_warn("%s: missing set() or set_debounce() operations\n",
>> __func__);
>> + return -EIO;
>> }
>
> BTW, I'm not sure that error-path should pr_warn(). For example, if this
> error-patch is taken due to a call from
> gpio_keys.c:gpio_keys_setup_key(), then a timer will be used for
> debounce instead, which is all perfectly valid, and probably not
> something that should be spewed to the kernel log.
You're right, I wasn't aware of the fallback use-case,
so I've proposed a separate patch fixing this.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-09-06 8:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-03 10:39 [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce() Thierry Reding
2013-09-03 10:39 ` [PATCH 2/2] gpio: Use proper indentation Thierry Reding
2013-09-03 12:11 ` Linus Walleij
2013-09-03 12:23 ` Thierry Reding
2013-09-03 12:10 ` [PATCH 1/2] gpio: Fix crash in gpiod_set_debounce() Linus Walleij
2013-09-03 15:34 ` Kevin Hilman
2013-09-03 20:25 ` Stephen Warren
2013-09-06 8:55 ` 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).