Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: xlp: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

In this case the driver uses .mask_ack() and .unmask()
and since I have a vague idea about the semantics of
.mask_ack() I added .irq_enable() to the existing .irq_disable()
and called into the gpiolib core from those callbacks
instead of mask/unmask.

Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Linus Walleij and committed by
Bartosz Golaszewski
2093bcd8 b4510f8f

+12 -2
+12 -2
drivers/gpio/gpio-xlp.c
··· 90 90 writel(value, addr + regset); 91 91 } 92 92 93 + static void xlp_gpio_irq_enable(struct irq_data *d) 94 + { 95 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 96 + 97 + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 98 + } 99 + 93 100 static void xlp_gpio_irq_disable(struct irq_data *d) 94 101 { 95 102 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); ··· 107 100 xlp_gpio_set_reg(priv->gpio_intr_en, d->hwirq, 0x0); 108 101 __clear_bit(d->hwirq, priv->gpio_enabled_mask); 109 102 spin_unlock_irqrestore(&priv->lock, flags); 103 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 110 104 } 111 105 112 106 static void xlp_gpio_irq_mask_ack(struct irq_data *d) ··· 171 163 static struct irq_chip xlp_gpio_irq_chip = { 172 164 .name = "XLP-GPIO", 173 165 .irq_mask_ack = xlp_gpio_irq_mask_ack, 166 + .irq_enable = xlp_gpio_irq_enable, 174 167 .irq_disable = xlp_gpio_irq_disable, 175 168 .irq_set_type = xlp_gpio_set_irq_type, 176 169 .irq_unmask = xlp_gpio_irq_unmask, 177 - .flags = IRQCHIP_ONESHOT_SAFE, 170 + .flags = IRQCHIP_ONESHOT_SAFE | IRQCHIP_IMMUTABLE, 171 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 178 172 }; 179 173 180 174 static void xlp_gpio_generic_handler(struct irq_desc *desc) ··· 282 272 spin_lock_init(&priv->lock); 283 273 284 274 girq = &gc->irq; 285 - girq->chip = &xlp_gpio_irq_chip; 275 + gpio_irq_chip_set_chip(girq, &xlp_gpio_irq_chip); 286 276 girq->parent_handler = xlp_gpio_generic_handler; 287 277 girq->num_parents = 1; 288 278 girq->parents = devm_kcalloc(&pdev->dev, 1,