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

gpio: ep93xx: Make irqchip immutable

This turns the Cirrus ep93xx gpio irqchip immutable.

Preserve per-chip labels by adding an ->irq_print_chip() callback.

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Nikita Shubin and committed by
Bartosz Golaszewski
216f3736 0f04cdbd

+21 -13
+21 -13
drivers/gpio/gpio-ep93xx.c
··· 17 17 #include <linux/slab.h> 18 18 #include <linux/gpio/driver.h> 19 19 #include <linux/bitops.h> 20 + #include <linux/seq_file.h> 20 21 21 22 #define EP93XX_GPIO_F_INT_STATUS 0x5c 22 23 #define EP93XX_GPIO_A_INT_STATUS 0xa0 ··· 41 40 #define EP93XX_GPIO_F_IRQ_BASE 80 42 41 43 42 struct ep93xx_gpio_irq_chip { 44 - struct irq_chip ic; 45 43 u8 irq_offset; 46 44 u8 int_unmasked; 47 45 u8 int_enabled; ··· 185 185 ep93xx_gpio_update_int_params(epg, eic); 186 186 187 187 writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET); 188 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 188 189 } 189 190 190 191 static void ep93xx_gpio_irq_mask(struct irq_data *d) ··· 196 195 197 196 eic->int_unmasked &= ~BIT(d->irq & 7); 198 197 ep93xx_gpio_update_int_params(epg, eic); 198 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 199 199 } 200 200 201 201 static void ep93xx_gpio_irq_unmask(struct irq_data *d) ··· 205 203 struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); 206 204 struct ep93xx_gpio *epg = gpiochip_get_data(gc); 207 205 206 + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 208 207 eic->int_unmasked |= BIT(d->irq & 7); 209 208 ep93xx_gpio_update_int_params(epg, eic); 210 209 } ··· 323 320 return 0; 324 321 } 325 322 326 - static void ep93xx_init_irq_chip(struct device *dev, struct irq_chip *ic) 323 + static void ep93xx_irq_print_chip(struct irq_data *data, struct seq_file *p) 327 324 { 328 - ic->irq_ack = ep93xx_gpio_irq_ack; 329 - ic->irq_mask_ack = ep93xx_gpio_irq_mask_ack; 330 - ic->irq_mask = ep93xx_gpio_irq_mask; 331 - ic->irq_unmask = ep93xx_gpio_irq_unmask; 332 - ic->irq_set_type = ep93xx_gpio_irq_type; 325 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 326 + 327 + seq_printf(p, dev_name(gc->parent)); 333 328 } 329 + 330 + static const struct irq_chip gpio_eic_irq_chip = { 331 + .name = "ep93xx-gpio-eic", 332 + .irq_ack = ep93xx_gpio_irq_ack, 333 + .irq_mask = ep93xx_gpio_irq_mask, 334 + .irq_unmask = ep93xx_gpio_irq_unmask, 335 + .irq_mask_ack = ep93xx_gpio_irq_mask_ack, 336 + .irq_set_type = ep93xx_gpio_irq_type, 337 + .irq_print_chip = ep93xx_irq_print_chip, 338 + .flags = IRQCHIP_IMMUTABLE, 339 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 340 + }; 334 341 335 342 static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc, 336 343 struct platform_device *pdev, ··· 372 359 if (!egc->eic) 373 360 return -ENOMEM; 374 361 egc->eic->irq_offset = bank->irq; 375 - ic = &egc->eic->ic; 376 - ic->name = devm_kasprintf(dev, GFP_KERNEL, "gpio-irq-%s", bank->label); 377 - if (!ic->name) 378 - return -ENOMEM; 379 - ep93xx_init_irq_chip(dev, ic); 380 - girq->chip = ic; 362 + gpio_irq_chip_set_chip(girq, &gpio_eic_irq_chip); 381 363 } 382 364 383 365 if (bank->has_irq) {