[2/2] i2c / ACPI: Assign IRQ for devices that have GpioInt automatically
diff mbox

Message ID 1430233507-29389-3-git-send-email-mika.westerberg@linux.intel.com
State New
Headers show

Commit Message

Mika Westerberg April 28, 2015, 3:05 p.m. UTC
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>
---
 drivers/i2c/i2c-core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Wolfram Sang April 29, 2015, 9:56 a.m. UTC | #1
> -	if (!client->irq && dev->of_node) {
> -		int irq = of_irq_get(dev->of_node, 0);
> +	if (client->irq <= 0) {
> +		int irq = -ENOENT;

Why the move from !client->irq to <= 0? If I didn't miss something,
interrupt numbers are still a sleeping dog with all the unsigned vs
signed fuzz. If this change is needed, this needs proper description and
ideally a seperate patch.
Mika Westerberg April 29, 2015, 10:02 a.m. UTC | #2
On Wed, Apr 29, 2015 at 11:56:06AM +0200, Wolfram Sang wrote:
> 
> > -	if (!client->irq && dev->of_node) {
> > -		int irq = of_irq_get(dev->of_node, 0);
> > +	if (client->irq <= 0) {
> > +		int irq = -ENOENT;
> 
> Why the move from !client->irq to <= 0? If I didn't miss something,
> interrupt numbers are still a sleeping dog with all the unsigned vs
> signed fuzz. If this change is needed, this needs proper description and
> ideally a seperate patch.

It is there because ACPI parts of I2C client enumeration code
initializes client->irq with -1. Alternatively we can change that code
to use 0 for missing IRQ.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 987c124432c5..01ef731281e2 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -632,8 +632,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 <= 0) {
+		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;