| From 78750aa343c1faf66ead1d6207f734f39ffe1891 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Thu, 13 Sep 2018 14:42:13 +0200 |
| Subject: pinctrl: at91: don't use the same irqchip with multiple gpiochips |
| |
| From: Ludovic Desroches <ludovic.desroches@microchip.com> |
| |
| [ Upstream commit 0c3dfa176912b5f87732545598200fb55e9c1978 ] |
| |
| Sharing the same irqchip with multiple gpiochips is not a good |
| practice. For instance, when installing hooks, we change the state |
| of the irqchip. The initial state of the irqchip for the second |
| gpiochip to register is then disrupted. |
| |
| Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com> |
| Signed-off-by: Linus Walleij <linus.walleij@linaro.org> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/pinctrl/pinctrl-at91.c | 28 ++++++++++++++-------------- |
| 1 file changed, 14 insertions(+), 14 deletions(-) |
| |
| diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c |
| index 50f0ec42c6372..fad0e132ead84 100644 |
| --- a/drivers/pinctrl/pinctrl-at91.c |
| +++ b/drivers/pinctrl/pinctrl-at91.c |
| @@ -1574,16 +1574,6 @@ void at91_pinctrl_gpio_resume(void) |
| #define gpio_irq_set_wake NULL |
| #endif /* CONFIG_PM */ |
| |
| -static struct irq_chip gpio_irqchip = { |
| - .name = "GPIO", |
| - .irq_ack = gpio_irq_ack, |
| - .irq_disable = gpio_irq_mask, |
| - .irq_mask = gpio_irq_mask, |
| - .irq_unmask = gpio_irq_unmask, |
| - /* .irq_set_type is set dynamically */ |
| - .irq_set_wake = gpio_irq_set_wake, |
| -}; |
| - |
| static void gpio_irq_handler(struct irq_desc *desc) |
| { |
| struct irq_chip *chip = irq_desc_get_chip(desc); |
| @@ -1624,12 +1614,22 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, |
| struct gpio_chip *gpiochip_prev = NULL; |
| struct at91_gpio_chip *prev = NULL; |
| struct irq_data *d = irq_get_irq_data(at91_gpio->pioc_virq); |
| + struct irq_chip *gpio_irqchip; |
| int ret, i; |
| |
| + gpio_irqchip = devm_kzalloc(&pdev->dev, sizeof(*gpio_irqchip), GFP_KERNEL); |
| + if (!gpio_irqchip) |
| + return -ENOMEM; |
| + |
| at91_gpio->pioc_hwirq = irqd_to_hwirq(d); |
| |
| - /* Setup proper .irq_set_type function */ |
| - gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type; |
| + gpio_irqchip->name = "GPIO"; |
| + gpio_irqchip->irq_ack = gpio_irq_ack; |
| + gpio_irqchip->irq_disable = gpio_irq_mask; |
| + gpio_irqchip->irq_mask = gpio_irq_mask; |
| + gpio_irqchip->irq_unmask = gpio_irq_unmask; |
| + gpio_irqchip->irq_set_wake = gpio_irq_set_wake, |
| + gpio_irqchip->irq_set_type = at91_gpio->ops->irq_type; |
| |
| /* Disable irqs of this PIO controller */ |
| writel_relaxed(~0, at91_gpio->regbase + PIO_IDR); |
| @@ -1640,7 +1640,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, |
| * interrupt. |
| */ |
| ret = gpiochip_irqchip_add(&at91_gpio->chip, |
| - &gpio_irqchip, |
| + gpio_irqchip, |
| 0, |
| handle_edge_irq, |
| IRQ_TYPE_NONE); |
| @@ -1658,7 +1658,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, |
| if (!gpiochip_prev) { |
| /* Then register the chain on the parent IRQ */ |
| gpiochip_set_chained_irqchip(&at91_gpio->chip, |
| - &gpio_irqchip, |
| + gpio_irqchip, |
| at91_gpio->pioc_virq, |
| gpio_irq_handler); |
| return 0; |
| -- |
| 2.20.1 |
| |