Skip to content

Commit

Permalink
i2c / ACPI: Assign IRQ for devices that have GpioInt automatically
Browse files Browse the repository at this point in the history
Following what DT already does. If the device does not have ACPI Interrupt
resource but instead it has one or more GpioInt resources listed below it,
we take the first GpioInt resource, convert it to suitable Linux IRQ number
and pass it to the driver instead.

This makes drivers simpler because the don't need to care about GPIOs at
all if only thing they need is interrupt.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Mika Westerberg authored and Linus Walleij committed May 13, 2015
1 parent dab472e commit 845c877
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,13 @@ static int i2c_device_probe(struct device *dev)
if (!client)
return 0;

if (!client->irq && dev->of_node) {
int irq = of_irq_get(dev->of_node, 0);
if (!client->irq) {
int irq = -ENOENT;

if (dev->of_node)
irq = of_irq_get(dev->of_node, 0);
else if (ACPI_COMPANION(dev))
irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0);

if (irq == -EPROBE_DEFER)
return irq;
Expand Down

0 comments on commit 845c877

Please sign in to comment.