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

pinctrl: pistachio: Convert to immutable irq_chip

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

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230414-immutable-irqchips-2-v1-2-6b59a5186b00@linaro.org

+25 -10
+25 -10
drivers/pinctrl/pinctrl-pistachio.c
··· 17 17 #include <linux/pinctrl/pinmux.h> 18 18 #include <linux/platform_device.h> 19 19 #include <linux/property.h> 20 + #include <linux/seq_file.h> 20 21 #include <linux/slab.h> 21 22 #include <linux/spinlock.h> 22 23 ··· 94 93 struct pistachio_gpio_bank { 95 94 struct pistachio_pinctrl *pctl; 96 95 void __iomem *base; 96 + int instance; 97 97 unsigned int pin_base; 98 98 unsigned int npins; 99 99 struct gpio_chip gpio_chip; 100 - struct irq_chip irq_chip; 101 100 }; 102 101 103 102 struct pistachio_pinctrl { ··· 1229 1228 struct pistachio_gpio_bank *bank = irqd_to_bank(data); 1230 1229 1231 1230 gpio_mask_writel(bank, GPIO_INTERRUPT_EN, data->hwirq, 0); 1231 + gpiochip_disable_irq(&bank->gpio_chip, irqd_to_hwirq(data)); 1232 1232 } 1233 1233 1234 1234 static void pistachio_gpio_irq_unmask(struct irq_data *data) 1235 1235 { 1236 1236 struct pistachio_gpio_bank *bank = irqd_to_bank(data); 1237 1237 1238 + gpiochip_enable_irq(&bank->gpio_chip, irqd_to_hwirq(data)); 1238 1239 gpio_mask_writel(bank, GPIO_INTERRUPT_EN, data->hwirq, 1); 1239 1240 } 1240 1241 ··· 1315 1312 1316 1313 #define GPIO_BANK(_bank, _pin_base, _npins) \ 1317 1314 { \ 1315 + .instance = (_bank), \ 1318 1316 .pin_base = _pin_base, \ 1319 1317 .npins = _npins, \ 1320 1318 .gpio_chip = { \ ··· 1330 1326 .base = _pin_base, \ 1331 1327 .ngpio = _npins, \ 1332 1328 }, \ 1333 - .irq_chip = { \ 1334 - .name = "GPIO" #_bank, \ 1335 - .irq_startup = pistachio_gpio_irq_startup, \ 1336 - .irq_ack = pistachio_gpio_irq_ack, \ 1337 - .irq_mask = pistachio_gpio_irq_mask, \ 1338 - .irq_unmask = pistachio_gpio_irq_unmask, \ 1339 - .irq_set_type = pistachio_gpio_irq_set_type, \ 1340 - }, \ 1341 1329 } 1342 1330 1343 1331 static struct pistachio_gpio_bank pistachio_gpio_banks[] = { ··· 1339 1343 GPIO_BANK(3, PISTACHIO_PIN_MFIO(48), 16), 1340 1344 GPIO_BANK(4, PISTACHIO_PIN_MFIO(64), 16), 1341 1345 GPIO_BANK(5, PISTACHIO_PIN_MFIO(80), 10), 1346 + }; 1347 + 1348 + static void pistachio_gpio_irq_print_chip(struct irq_data *data, 1349 + struct seq_file *p) 1350 + { 1351 + struct pistachio_gpio_bank *bank = irqd_to_bank(data); 1352 + 1353 + seq_printf(p, "GPIO%d", bank->instance); 1354 + } 1355 + 1356 + static const struct irq_chip pistachio_gpio_irq_chip = { 1357 + .irq_startup = pistachio_gpio_irq_startup, 1358 + .irq_ack = pistachio_gpio_irq_ack, 1359 + .irq_mask = pistachio_gpio_irq_mask, 1360 + .irq_unmask = pistachio_gpio_irq_unmask, 1361 + .irq_set_type = pistachio_gpio_irq_set_type, 1362 + .irq_print_chip = pistachio_gpio_irq_print_chip, 1363 + .flags = IRQCHIP_IMMUTABLE, 1364 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 1342 1365 }; 1343 1366 1344 1367 static int pistachio_gpio_register(struct pistachio_pinctrl *pctl) ··· 1409 1394 bank->gpio_chip.fwnode = child; 1410 1395 1411 1396 girq = &bank->gpio_chip.irq; 1412 - girq->chip = &bank->irq_chip; 1397 + gpio_irq_chip_set_chip(girq, &pistachio_gpio_irq_chip); 1413 1398 girq->parent_handler = pistachio_gpio_irq_handler; 1414 1399 girq->num_parents = 1; 1415 1400 girq->parents = devm_kcalloc(pctl->dev, 1,