* [PATCH] pinctrl: pistachio: Pass irqchip when adding gpiochip
@ 2019-10-01 21:45 Linus Walleij
2019-10-03 15:03 ` James Hartley
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2019-10-01 21:45 UTC (permalink / raw)
To: linux-gpio
Cc: Bartosz Golaszewski, Linus Walleij, Andrew Bresticker,
James Hartley, Thierry Reding
We need to convert all old gpio irqchips to pass the irqchip
setup along when adding the gpio_chip. For more info see
drivers/gpio/TODO.
For chained irqchips this is a pretty straight-forward
conversion.
Cc: Andrew Bresticker <abrestic@chromium.org>
Cc: James Hartley <james.hartley@sondrel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/pinctrl/pinctrl-pistachio.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
index 379e9a6a6d89..eb40ae9f8639 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -1352,6 +1352,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
for (i = 0; i < pctl->nbanks; i++) {
char child_name[sizeof("gpioXX")];
struct device_node *child;
+ struct gpio_irq_chip *girq;
snprintf(child_name, sizeof(child_name), "gpio%d", i);
child = of_get_child_by_name(node, child_name);
@@ -1383,23 +1384,28 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
bank->gpio_chip.parent = pctl->dev;
bank->gpio_chip.of_node = child;
- ret = gpiochip_add_data(&bank->gpio_chip, bank);
- if (ret < 0) {
- dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n",
- i, ret);
+
+ girq = &bank->gpio_chip.irq;
+ girq->chip = &bank->irq_chip;
+ girq->parent_handler = pistachio_gpio_irq_handler;
+ girq->num_parents = 1;
+ girq->parents = devm_kcalloc(pctl->dev, 1,
+ sizeof(*girq->parents),
+ GFP_KERNEL);
+ if (!girq->parents) {
+ ret = -ENOMEM;
goto err;
}
+ girq->parents[0] = irq;
+ girq->default_type = IRQ_TYPE_NONE;
+ girq->handler = handle_level_irq;
- ret = gpiochip_irqchip_add(&bank->gpio_chip, &bank->irq_chip,
- 0, handle_level_irq, IRQ_TYPE_NONE);
+ ret = gpiochip_add_data(&bank->gpio_chip, bank);
if (ret < 0) {
- dev_err(pctl->dev, "Failed to add IRQ chip %u: %d\n",
+ dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n",
i, ret);
- gpiochip_remove(&bank->gpio_chip);
goto err;
}
- gpiochip_set_chained_irqchip(&bank->gpio_chip, &bank->irq_chip,
- irq, pistachio_gpio_irq_handler);
ret = gpiochip_add_pin_range(&bank->gpio_chip,
dev_name(pctl->dev), 0,
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pinctrl: pistachio: Pass irqchip when adding gpiochip
2019-10-01 21:45 [PATCH] pinctrl: pistachio: Pass irqchip when adding gpiochip Linus Walleij
@ 2019-10-03 15:03 ` James Hartley
0 siblings, 0 replies; 2+ messages in thread
From: James Hartley @ 2019-10-03 15:03 UTC (permalink / raw)
To: Linus Walleij, linux-gpio@vger.kernel.org
Cc: Bartosz Golaszewski, Andrew Bresticker, Thierry Reding
Hi Linus,
On 01/10/2019 22:45, Linus Walleij wrote:
> We need to convert all old gpio irqchips to pass the irqchip
> setup along when adding the gpio_chip. For more info see
> drivers/gpio/TODO.
>
> For chained irqchips this is a pretty straight-forward
> conversion.
>
> Cc: Andrew Bresticker <abrestic@chromium.org>
> Cc: James Hartley <james.hartley@sondrel.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/pinctrl/pinctrl-pistachio.c | 26 ++++++++++++++++----------
> 1 file changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
> index 379e9a6a6d89..eb40ae9f8639 100644
> --- a/drivers/pinctrl/pinctrl-pistachio.c
> +++ b/drivers/pinctrl/pinctrl-pistachio.c
> @@ -1352,6 +1352,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
> for (i = 0; i < pctl->nbanks; i++) {
> char child_name[sizeof("gpioXX")];
> struct device_node *child;
> + struct gpio_irq_chip *girq;
>
> snprintf(child_name, sizeof(child_name), "gpio%d", i);
> child = of_get_child_by_name(node, child_name);
> @@ -1383,23 +1384,28 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
>
> bank->gpio_chip.parent = pctl->dev;
> bank->gpio_chip.of_node = child;
> - ret = gpiochip_add_data(&bank->gpio_chip, bank);
> - if (ret < 0) {
> - dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n",
> - i, ret);
> +
> + girq = &bank->gpio_chip.irq;
> + girq->chip = &bank->irq_chip;
> + girq->parent_handler = pistachio_gpio_irq_handler;
> + girq->num_parents = 1;
> + girq->parents = devm_kcalloc(pctl->dev, 1,
> + sizeof(*girq->parents),
> + GFP_KERNEL);
> + if (!girq->parents) {
> + ret = -ENOMEM;
> goto err;
> }
> + girq->parents[0] = irq;
> + girq->default_type = IRQ_TYPE_NONE;
> + girq->handler = handle_level_irq;
>
> - ret = gpiochip_irqchip_add(&bank->gpio_chip, &bank->irq_chip,
> - 0, handle_level_irq, IRQ_TYPE_NONE);
> + ret = gpiochip_add_data(&bank->gpio_chip, bank);
> if (ret < 0) {
> - dev_err(pctl->dev, "Failed to add IRQ chip %u: %d\n",
> + dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n",
> i, ret);
> - gpiochip_remove(&bank->gpio_chip);
> goto err;
> }
> - gpiochip_set_chained_irqchip(&bank->gpio_chip, &bank->irq_chip,
> - irq, pistachio_gpio_irq_handler);
>
> ret = gpiochip_add_pin_range(&bank->gpio_chip,
> dev_name(pctl->dev), 0,
I don't have a platform right now to test this but as you say, this is a
straight forward conversion. Thanks for the patch. ACK.
James.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-03 15:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-01 21:45 [PATCH] pinctrl: pistachio: Pass irqchip when adding gpiochip Linus Walleij
2019-10-03 15:03 ` James Hartley
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).