pinctrl: microchip-sgpio: make irq_chip immutable
authorMichael Walle <michael@walle.cc>
Thu, 28 Apr 2022 11:16:22 +0000 (13:16 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 5 May 2022 14:53:25 +0000 (16:53 +0200)
Since recently, the kernel is nagging about mutable irq_chips:

[    4.967050] gpio gpiochip1: (e2004190.gpio-input): not an immutable chip, please consider fixing it!

Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new
helper functions and call the appropriate gpiolib functions.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220428111622.1395831-1-michael@walle.cc
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-microchip-sgpio.c

index 80a8939..6dbe37d 100644 (file)
@@ -688,11 +688,17 @@ static void microchip_sgpio_irq_setreg(struct irq_data *data,
 
 static void microchip_sgpio_irq_mask(struct irq_data *data)
 {
+       struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
+
        microchip_sgpio_irq_setreg(data, REG_INT_ENABLE, true);
+       gpiochip_disable_irq(chip, data->hwirq);
 }
 
 static void microchip_sgpio_irq_unmask(struct irq_data *data)
 {
+       struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
+
+       gpiochip_enable_irq(chip, data->hwirq);
        microchip_sgpio_irq_setreg(data, REG_INT_ENABLE, false);
 }
 
@@ -746,6 +752,8 @@ static const struct irq_chip microchip_sgpio_irqchip = {
        .irq_ack        = microchip_sgpio_irq_ack,
        .irq_unmask     = microchip_sgpio_irq_unmask,
        .irq_set_type   = microchip_sgpio_irq_set_type,
+       .flags          = IRQCHIP_IMMUTABLE,
+       GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static void sgpio_irq_handler(struct irq_desc *desc)
@@ -861,11 +869,7 @@ static int microchip_sgpio_register_bank(struct device *dev,
                if (irq) {
                        struct gpio_irq_chip *girq = &gc->irq;
 
-                       girq->chip = devm_kmemdup(dev, &microchip_sgpio_irqchip,
-                                                 sizeof(microchip_sgpio_irqchip),
-                                                 GFP_KERNEL);
-                       if (!girq->chip)
-                               return -ENOMEM;
+                       gpio_irq_chip_set_chip(girq, &microchip_sgpio_irqchip);
                        girq->parent_handler = sgpio_irq_handler;
                        girq->num_parents = 1;
                        girq->parents = devm_kcalloc(dev, 1,