pinctrl: coh901: Pass irqchip when adding gpiochip
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 13 Sep 2019 11:35:25 +0000 (13:35 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 30 Sep 2019 21:10:01 +0000 (23:10 +0200)
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: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20190913113530.5536-1-linus.walleij@linaro.org
drivers/pinctrl/pinctrl-coh901.c

index 08b9e90..063a629 100644 (file)
@@ -616,6 +616,7 @@ static int __init u300_gpio_probe(struct platform_device *pdev)
 {
        struct u300_gpio *gpio;
        struct resource *memres;
+       struct gpio_irq_chip *girq;
        int err = 0;
        int portno;
        u32 val;
@@ -672,26 +673,17 @@ static int __init u300_gpio_probe(struct platform_device *pdev)
               gpio->base + U300_GPIO_CR);
        u300_gpio_init_coh901571(gpio);
 
-#ifdef CONFIG_OF_GPIO
-       gpio->chip.of_node = pdev->dev.of_node;
-#endif
-       err = gpiochip_add_data(&gpio->chip, gpio);
-       if (err) {
-               dev_err(gpio->dev, "unable to add gpiochip: %d\n", err);
-               goto err_no_chip;
-       }
-
-       err = gpiochip_irqchip_add(&gpio->chip,
-                                  &u300_gpio_irqchip,
-                                  0,
-                                  handle_simple_irq,
-                                  IRQ_TYPE_EDGE_FALLING);
-       if (err) {
-               dev_err(gpio->dev, "no GPIO irqchip\n");
-               goto err_no_irqchip;
+       girq = &gpio->chip.irq;
+       girq->chip = &u300_gpio_irqchip;
+       girq->parent_handler = u300_gpio_irq_handler;
+       girq->num_parents = U300_GPIO_NUM_PORTS;
+       girq->parents = devm_kcalloc(gpio->dev, U300_GPIO_NUM_PORTS,
+                                    sizeof(*girq->parents),
+                                    GFP_KERNEL);
+       if (!girq->parents) {
+               err = -ENOMEM;
+               goto err_dis_clk;
        }
-
-       /* Add each port with its IRQ separately */
        for (portno = 0 ; portno < U300_GPIO_NUM_PORTS; portno++) {
                struct u300_gpio_port *port = &gpio->ports[portno];
 
@@ -700,16 +692,21 @@ static int __init u300_gpio_probe(struct platform_device *pdev)
                port->gpio = gpio;
 
                port->irq = platform_get_irq(pdev, portno);
-
-               gpiochip_set_chained_irqchip(&gpio->chip,
-                                            &u300_gpio_irqchip,
-                                            port->irq,
-                                            u300_gpio_irq_handler);
+               girq->parents[portno] = port->irq;
 
                /* Turns off irq force (test register) for this port */
                writel(0x0, gpio->base + portno * gpio->stride + ifr);
        }
-       dev_dbg(gpio->dev, "initialized %d GPIO ports\n", portno);
+       girq->default_type = IRQ_TYPE_EDGE_FALLING;
+       girq->handler = handle_simple_irq;
+#ifdef CONFIG_OF_GPIO
+       gpio->chip.of_node = pdev->dev.of_node;
+#endif
+       err = gpiochip_add_data(&gpio->chip, gpio);
+       if (err) {
+               dev_err(gpio->dev, "unable to add gpiochip: %d\n", err);
+               goto err_dis_clk;
+       }
 
        /*
         * Add pinctrl pin ranges, the pin controller must be registered
@@ -729,9 +726,8 @@ static int __init u300_gpio_probe(struct platform_device *pdev)
        return 0;
 
 err_no_range:
-err_no_irqchip:
        gpiochip_remove(&gpio->chip);
-err_no_chip:
+err_dis_clk:
        clk_disable_unprepare(gpio->clk);
        dev_err(&pdev->dev, "module ERROR:%d\n", err);
        return err;