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

gpio: tqmx86: Convert to immutable irq_chip

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

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
8e43827b ef902f54

+20 -8
+20 -8
drivers/gpio/gpio-tqmx86.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/platform_device.h> 17 17 #include <linux/pm_runtime.h> 18 + #include <linux/seq_file.h> 18 19 #include <linux/slab.h> 19 20 20 21 #define TQMX86_NGPIO 8 ··· 35 34 36 35 struct tqmx86_gpio_data { 37 36 struct gpio_chip chip; 38 - struct irq_chip irq_chip; 39 37 void __iomem *io_base; 40 38 int irq; 41 39 raw_spinlock_t spinlock; ··· 122 122 gpiic &= ~mask; 123 123 tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC); 124 124 raw_spin_unlock_irqrestore(&gpio->spinlock, flags); 125 + gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(data)); 125 126 } 126 127 127 128 static void tqmx86_gpio_irq_unmask(struct irq_data *data) ··· 135 134 136 135 mask = TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS); 137 136 137 + gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(data)); 138 138 raw_spin_lock_irqsave(&gpio->spinlock, flags); 139 139 gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC); 140 140 gpiic &= ~mask; ··· 228 226 clear_bit(3, valid_mask); 229 227 } 230 228 229 + static void tqmx86_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) 230 + { 231 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 232 + 233 + seq_printf(p, gc->label); 234 + } 235 + 236 + static const struct irq_chip tqmx86_gpio_irq_chip = { 237 + .irq_mask = tqmx86_gpio_irq_mask, 238 + .irq_unmask = tqmx86_gpio_irq_unmask, 239 + .irq_set_type = tqmx86_gpio_irq_set_type, 240 + .irq_print_chip = tqmx86_gpio_irq_print_chip, 241 + .flags = IRQCHIP_IMMUTABLE, 242 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 243 + }; 244 + 231 245 static int tqmx86_gpio_probe(struct platform_device *pdev) 232 246 { 233 247 struct device *dev = &pdev->dev; ··· 295 277 pm_runtime_enable(&pdev->dev); 296 278 297 279 if (irq > 0) { 298 - struct irq_chip *irq_chip = &gpio->irq_chip; 299 280 u8 irq_status; 300 - 301 - irq_chip->name = chip->label; 302 - irq_chip->irq_mask = tqmx86_gpio_irq_mask; 303 - irq_chip->irq_unmask = tqmx86_gpio_irq_unmask; 304 - irq_chip->irq_set_type = tqmx86_gpio_irq_set_type; 305 281 306 282 /* Mask all interrupts */ 307 283 tqmx86_gpio_write(gpio, 0, TQMX86_GPIIC); ··· 305 293 tqmx86_gpio_write(gpio, irq_status, TQMX86_GPIIS); 306 294 307 295 girq = &chip->irq; 308 - girq->chip = irq_chip; 296 + gpio_irq_chip_set_chip(girq, &tqmx86_gpio_irq_chip); 309 297 girq->parent_handler = tqmx86_gpio_irq_handler; 310 298 girq->num_parents = 1; 311 299 girq->parents = devm_kcalloc(&pdev->dev, 1,