* [PATCH] gpio: stmpe: Use irqchip template
@ 2020-07-16 10:06 Linus Walleij
2020-07-27 12:32 ` Patrice CHOTARD
2020-07-27 21:13 ` Serge Semin
0 siblings, 2 replies; 4+ messages in thread
From: Linus Walleij @ 2020-07-16 10:06 UTC (permalink / raw)
To: linux-gpio
Cc: Bartosz Golaszewski, Linus Walleij, Patrice Chotard, Alexandre TORGUE
This makes the driver use the irqchip template to assign
properties to the gpio_irq_chip instead of using the
explicit calls to gpiochip_irqchip_add_nested() and
gpiochip_set_nested_irqchip(). The irqchip is instead
added while adding the gpiochip.
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpio-stmpe.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 542706a852e6..395ee51445ea 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -507,6 +507,8 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
}
if (irq > 0) {
+ struct gpio_irq_chip *girq;
+
ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
stmpe_gpio_irq, IRQF_ONESHOT,
"stmpe-gpio", stmpe_gpio);
@@ -514,20 +516,16 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
goto out_disable;
}
- ret = gpiochip_irqchip_add_nested(&stmpe_gpio->chip,
- &stmpe_gpio_irq_chip,
- 0,
- handle_simple_irq,
- IRQ_TYPE_NONE);
- if (ret) {
- dev_err(&pdev->dev,
- "could not connect irqchip to gpiochip\n");
- goto out_disable;
- }
- gpiochip_set_nested_irqchip(&stmpe_gpio->chip,
- &stmpe_gpio_irq_chip,
- irq);
+ girq = &stmpe_gpio->chip.irq;
+ girq->chip = &stmpe_gpio_irq_chip;
+ /* This will let us handle the parent IRQ in the driver */
+ girq->parent_handler = NULL;
+ girq->num_parents = 0;
+ girq->parents = NULL;
+ girq->default_type = IRQ_TYPE_NONE;
+ girq->handler = handle_simple_irq;
+ girq->threaded = true;
}
platform_set_drvdata(pdev, stmpe_gpio);
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: stmpe: Use irqchip template
2020-07-16 10:06 [PATCH] gpio: stmpe: Use irqchip template Linus Walleij
@ 2020-07-27 12:32 ` Patrice CHOTARD
2020-07-27 21:13 ` Serge Semin
1 sibling, 0 replies; 4+ messages in thread
From: Patrice CHOTARD @ 2020-07-27 12:32 UTC (permalink / raw)
To: Linus Walleij, linux-gpio; +Cc: Bartosz Golaszewski, Alexandre TORGUE
Hi Linus
On 7/16/20 12:06 PM, Linus Walleij wrote:
> This makes the driver use the irqchip template to assign
> properties to the gpio_irq_chip instead of using the
> explicit calls to gpiochip_irqchip_add_nested() and
> gpiochip_set_nested_irqchip(). The irqchip is instead
> added while adding the gpiochip.
>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Cc: Alexandre TORGUE <alexandre.torgue@st.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/gpio/gpio-stmpe.c | 24 +++++++++++-------------
> 1 file changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 542706a852e6..395ee51445ea 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -507,6 +507,8 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
> }
>
> if (irq > 0) {
> + struct gpio_irq_chip *girq;
> +
> ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
> stmpe_gpio_irq, IRQF_ONESHOT,
> "stmpe-gpio", stmpe_gpio);
> @@ -514,20 +516,16 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
> dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
> goto out_disable;
> }
> - ret = gpiochip_irqchip_add_nested(&stmpe_gpio->chip,
> - &stmpe_gpio_irq_chip,
> - 0,
> - handle_simple_irq,
> - IRQ_TYPE_NONE);
> - if (ret) {
> - dev_err(&pdev->dev,
> - "could not connect irqchip to gpiochip\n");
> - goto out_disable;
> - }
>
> - gpiochip_set_nested_irqchip(&stmpe_gpio->chip,
> - &stmpe_gpio_irq_chip,
> - irq);
> + girq = &stmpe_gpio->chip.irq;
> + girq->chip = &stmpe_gpio_irq_chip;
> + /* This will let us handle the parent IRQ in the driver */
> + girq->parent_handler = NULL;
> + girq->num_parents = 0;
> + girq->parents = NULL;
> + girq->default_type = IRQ_TYPE_NONE;
> + girq->handler = handle_simple_irq;
> + girq->threaded = true;
> }
>
> platform_set_drvdata(pdev, stmpe_gpio);
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: stmpe: Use irqchip template
2020-07-16 10:06 [PATCH] gpio: stmpe: Use irqchip template Linus Walleij
2020-07-27 12:32 ` Patrice CHOTARD
@ 2020-07-27 21:13 ` Serge Semin
2020-07-28 7:28 ` Linus Walleij
1 sibling, 1 reply; 4+ messages in thread
From: Serge Semin @ 2020-07-27 21:13 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-gpio, Bartosz Golaszewski, Patrice Chotard, Alexandre TORGUE
On Thu, Jul 16, 2020 at 12:06:38PM +0200, Linus Walleij wrote:
> This makes the driver use the irqchip template to assign
> properties to the gpio_irq_chip instead of using the
> explicit calls to gpiochip_irqchip_add_nested() and
> gpiochip_set_nested_irqchip(). The irqchip is instead
> added while adding the gpiochip.
>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Cc: Alexandre TORGUE <alexandre.torgue@st.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/gpio/gpio-stmpe.c | 24 +++++++++++-------------
> 1 file changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 542706a852e6..395ee51445ea 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -507,6 +507,8 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
> }
>
> if (irq > 0) {
> + struct gpio_irq_chip *girq;
> +
> ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
> stmpe_gpio_irq, IRQF_ONESHOT,
> "stmpe-gpio", stmpe_gpio);
> @@ -514,20 +516,16 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
> dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
> goto out_disable;
> }
> - ret = gpiochip_irqchip_add_nested(&stmpe_gpio->chip,
> - &stmpe_gpio_irq_chip,
> - 0,
> - handle_simple_irq,
> - IRQ_TYPE_NONE);
> - if (ret) {
> - dev_err(&pdev->dev,
> - "could not connect irqchip to gpiochip\n");
> - goto out_disable;
> - }
>
> - gpiochip_set_nested_irqchip(&stmpe_gpio->chip,
> - &stmpe_gpio_irq_chip,
> - irq);
> + girq = &stmpe_gpio->chip.irq;
> + girq->chip = &stmpe_gpio_irq_chip;
> + /* This will let us handle the parent IRQ in the driver */
> + girq->parent_handler = NULL;
> + girq->num_parents = 0;
> + girq->parents = NULL;
> + girq->default_type = IRQ_TYPE_NONE;
> + girq->handler = handle_simple_irq;
> + girq->threaded = true;
Hmm, the GPIO-irq-chip setting are initialized after the GPIO-chip has been
registered by calling the gpiochip_add_data() method earlier in this method.
That means the IRQ-chip won't be created by the GPIOlib, which will introduce a
bug. In order to fix the problem it's better to move the whole "if (irq > 0)
{...}" clause to be executed before the gpiochip_add_data() function invocation.
Though I could misunderstood something...
-Sergey
> }
>
> platform_set_drvdata(pdev, stmpe_gpio);
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: stmpe: Use irqchip template
2020-07-27 21:13 ` Serge Semin
@ 2020-07-28 7:28 ` Linus Walleij
0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2020-07-28 7:28 UTC (permalink / raw)
To: Serge Semin
Cc: open list:GPIO SUBSYSTEM, Bartosz Golaszewski, Patrice Chotard,
Alexandre TORGUE
On Mon, Jul 27, 2020 at 11:13 PM Serge Semin <fancer.lancer@gmail.com> wrote:
> Hmm, the GPIO-irq-chip setting are initialized after the GPIO-chip has been
> registered by calling the gpiochip_add_data() method earlier in this method.
> That means the IRQ-chip won't be created by the GPIOlib, which will introduce a
> bug. In order to fix the problem it's better to move the whole "if (irq > 0)
> {...}" clause to be executed before the gpiochip_add_data() function invocation.
>
> Though I could misunderstood something...
Ah what a mistake, thank you so much for looking through this patch and
spotting this! I sent a fix.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-07-28 7:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16 10:06 [PATCH] gpio: stmpe: Use irqchip template Linus Walleij
2020-07-27 12:32 ` Patrice CHOTARD
2020-07-27 21:13 ` Serge Semin
2020-07-28 7:28 ` 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).