Re: [PATCH v4] gpio: Add support for Intel SoC PMIC (Crystal Cove)
From: Linus Walleij
Date: Tue Jun 03 2014 - 04:08:12 EST
On Fri, May 30, 2014 at 4:12 AM, Zhu, Lejun <lejun.zhu@xxxxxxxxxxxxxxx> wrote:
> retval = gpiochip_add(&cg->chip);
> if (retval) {
> dev_warn(&pdev->dev, "add gpio chip error: %d\n", retval);
> return ret;
> }
>
> gpiochip_irqchip_add(&cg->chip, &crystalcove_irqchip, 0,
> handle_simple_irq, IRQ_TYPE_NONE);
>
> retval = request_threaded_irq(irq, NULL, crystalcove_gpio_irq_handler,
> IRQF_ONESHOT, KBUILD_MODNAME, cg);
You should request the interrupt before you add the irqchip
I think. But it shouldn't really matter, mainly to avoid tearing
down the irqchip if getting the irq should fail.
> But this code will trigger a crash in gpiolib-acpi. Currently at the end
> of gpiochip_add(), it calls:
>
> gpiochip_add() -> acpi_gpiochip_add() -> acpi_gpiochip_request_interrupts()
>
> acpi_gpiochip_request_interrupts() needs ->to_irq to work. Without having
> called gpiochip_irqchip_add() already, this will be NULL:
>
> if (!chip->to_irq)
> return; <-- It will return here.
>
> INIT_LIST_HEAD(&acpi_gpio->events);
>
> In the tear down path, acpi_gpiochip_free_interrupts() will find to_irq is
> no longer NULL, then it will walk an uninitialized list.
>
> So, should this be fixed in gpiolib-acpi?
Maybe, maybe in the drivers. I think Mika has a proposed solution...
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/