From: Mika Westerberg Date: Wed, 6 May 2015 10:29:08 +0000 (+0300) Subject: i2c / ACPI: Assign IRQ for devices that have GpioInt automatically X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=845c877009cf014b971aab7f54613f9185a824b0;p=linux-beck.git i2c / ACPI: Assign IRQ for devices that have GpioInt automatically 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 Acked-by: Wolfram Sang Signed-off-by: Linus Walleij --- diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index c21b3de70234..fc2ee8213fb6 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -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;