* [PATCH] gpio: be more careful when forcing IRQ line to input
@ 2016-07-05 14:15 Linus Walleij
2016-07-05 17:36 ` Sergei Shtylyov
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2016-07-05 14:15 UTC (permalink / raw)
To: linux-gpio, Alexandre Courbot; +Cc: Linus Walleij, Linux-Renesas
We need to convince the IRQ line to become input unless there
is a reason for. Also fixes up reference counting on the
errorpath.
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Geert: does this solve the problem you saw in the RCAR
in "gpio: convince line to become input in irq helper"?
---
drivers/gpio/gpiolib.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 69efe278f74d..e3e3cc19b8b0 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1505,25 +1505,32 @@ static const struct irq_domain_ops gpiochip_domain_ops = {
static int gpiochip_irq_reqres(struct irq_data *d)
{
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
+ struct gpio_desc *desc;
if (!try_module_get(chip->gpiodev->owner))
return -ENODEV;
+ /* Look up the corresponding descriptor */
+ desc = gpiochip_get_desc(chip, d->hwirq);
+ if (IS_ERR(desc)) {
+ module_put(chip->gpiodev->owner);
+ return PTR_ERR(desc);
+ }
+
/*
- * If it is possible to switch this GPIO to an input
- * this is a good time to do it.
+ * If the pin is flagged as output and it is possible to
+ * switch this GPIO to an input this is a good time to
+ * do it.
*/
- if (chip->direction_input) {
- struct gpio_desc *desc;
+ if (test_bit(FLAG_IS_OUT, &desc->flags) &&
+ chip->direction_input) {
int ret;
- desc = gpiochip_get_desc(chip, d->hwirq);
- if (IS_ERR(desc))
- return PTR_ERR(desc);
-
ret = chip->direction_input(chip, d->hwirq);
- if (ret)
+ if (ret) {
+ module_put(chip->gpiodev->owner);
return ret;
+ }
clear_bit(FLAG_IS_OUT, &desc->flags);
}
--
2.4.11
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: be more careful when forcing IRQ line to input
2016-07-05 14:15 [PATCH] gpio: be more careful when forcing IRQ line to input Linus Walleij
@ 2016-07-05 17:36 ` Sergei Shtylyov
2016-07-06 8:34 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2016-07-05 17:36 UTC (permalink / raw)
To: Linus Walleij, linux-gpio, Alexandre Courbot; +Cc: Linux-Renesas
Hello.
On 07/05/2016 05:15 PM, Linus Walleij wrote:
> We need to convince the IRQ line to become input unless there
> is a reason for. Also fixes up reference counting on the
For what?
> errorpath.
>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Linux-Renesas <linux-renesas-soc@vger.kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Geert: does this solve the problem you saw in the RCAR
> in "gpio: convince line to become input in irq helper"?
[...]
MBR, Sergei
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: be more careful when forcing IRQ line to input
2016-07-05 17:36 ` Sergei Shtylyov
@ 2016-07-06 8:34 ` Linus Walleij
0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2016-07-06 8:34 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Linux-Renesas
On Tue, Jul 5, 2016 at 7:36 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> Hello.
>
> On 07/05/2016 05:15 PM, Linus Walleij wrote:
>
>> We need to convince the IRQ line to become input unless there
>> is a reason for. Also fixes up reference counting on the
>
>
> For what?
Module refcount in its kobject. I'll update the commitlog.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-06 8:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-05 14:15 [PATCH] gpio: be more careful when forcing IRQ line to input Linus Walleij
2016-07-05 17:36 ` Sergei Shtylyov
2016-07-06 8:34 ` 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).