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

gpio: hlwd: Pass irqchip when adding gpiochip

We need to convert all old gpio irqchips to pass the irqchip
setup along when adding the gpio_chip. For more info see
drivers/gpio/TODO.

For chained irqchips this is a pretty straight-forward
conversion.

Cc: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20190809140005.11654-1-linus.walleij@linaro.org
Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Tested-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+29 -27
+29 -27
drivers/gpio/gpio-hlwd.c
··· 244 244 ngpios = 32; 245 245 hlwd->gpioc.ngpio = ngpios; 246 246 247 - res = devm_gpiochip_add_data(&pdev->dev, &hlwd->gpioc, hlwd); 248 - if (res) 249 - return res; 250 - 251 247 /* Mask and ack all interrupts */ 252 248 iowrite32be(0, hlwd->regs + HW_GPIOB_INTMASK); 253 249 iowrite32be(0xffffffff, hlwd->regs + HW_GPIOB_INTFLAG); 254 250 255 251 /* 256 252 * If this GPIO controller is not marked as an interrupt controller in 257 - * the DT, return. 253 + * the DT, skip interrupt support. 258 254 */ 259 - if (!of_property_read_bool(pdev->dev.of_node, "interrupt-controller")) 260 - return 0; 255 + if (of_property_read_bool(pdev->dev.of_node, "interrupt-controller")) { 256 + struct gpio_irq_chip *girq; 261 257 262 - hlwd->irq = platform_get_irq(pdev, 0); 263 - if (hlwd->irq < 0) { 264 - dev_info(&pdev->dev, "platform_get_irq returned %d\n", 265 - hlwd->irq); 266 - return hlwd->irq; 258 + hlwd->irq = platform_get_irq(pdev, 0); 259 + if (hlwd->irq < 0) { 260 + dev_info(&pdev->dev, "platform_get_irq returned %d\n", 261 + hlwd->irq); 262 + return hlwd->irq; 263 + } 264 + 265 + hlwd->irqc.name = dev_name(&pdev->dev); 266 + hlwd->irqc.irq_mask = hlwd_gpio_irq_mask; 267 + hlwd->irqc.irq_unmask = hlwd_gpio_irq_unmask; 268 + hlwd->irqc.irq_enable = hlwd_gpio_irq_enable; 269 + hlwd->irqc.irq_set_type = hlwd_gpio_irq_set_type; 270 + 271 + girq = &hlwd->gpioc.irq; 272 + girq->chip = &hlwd->irqc; 273 + girq->parent_handler = hlwd_gpio_irqhandler; 274 + girq->num_parents = 1; 275 + girq->parents = devm_kcalloc(&pdev->dev, 1, 276 + sizeof(*girq->parents), 277 + GFP_KERNEL); 278 + if (!girq->parents) 279 + return -ENOMEM; 280 + girq->parents[0] = hlwd->irq; 281 + girq->default_type = IRQ_TYPE_NONE; 282 + girq->handler = handle_level_irq; 267 283 } 268 284 269 - hlwd->irqc.name = dev_name(&pdev->dev); 270 - hlwd->irqc.irq_mask = hlwd_gpio_irq_mask; 271 - hlwd->irqc.irq_unmask = hlwd_gpio_irq_unmask; 272 - hlwd->irqc.irq_enable = hlwd_gpio_irq_enable; 273 - hlwd->irqc.irq_set_type = hlwd_gpio_irq_set_type; 274 - 275 - res = gpiochip_irqchip_add(&hlwd->gpioc, &hlwd->irqc, 0, 276 - handle_level_irq, IRQ_TYPE_NONE); 277 - if (res) 278 - return res; 279 - 280 - gpiochip_set_chained_irqchip(&hlwd->gpioc, &hlwd->irqc, 281 - hlwd->irq, hlwd_gpio_irqhandler); 282 - 283 - return 0; 285 + return devm_gpiochip_add_data(&pdev->dev, &hlwd->gpioc, hlwd); 284 286 } 285 287 286 288 static const struct of_device_id hlwd_gpio_match[] = {