From: Hans de Goede <hdegoede@redhat.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c@vger.kernel.org, Hans de Goede <hdegoede@redhat.com>
Subject: [PATCH v2 3/3] i2c: core: Allow drivers to specify index for irq to get from of / acpi
Date: Sat, 11 Mar 2017 00:57:03 +0100 [thread overview]
Message-ID: <20170310235703.29984-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20170310235703.29984-1-hdegoede@redhat.com>
Some of or acpi declared / enumerated devices may have multiple irq
resources declared and the driver may want to use a different irq then
the one with index 0.
This commit adds a new irq_index field to struct i2c_driver and makes
the i2c-core pass this to of_irq_get / acpi_dev_gpio_irq_get.
This is esp. useful for acpi declared devices where the irq with
index 0 may be entirely useless and cause i2c_device_probe to fail with
-EPROBE_DEFER.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Actually also use the irq_index for of interrupts
---
drivers/i2c/i2c-core.c | 8 ++++++--
include/linux/i2c.h | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 8ddd55b..f016278 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -984,6 +984,8 @@ static int i2c_device_probe(struct device *dev)
if (!client)
return 0;
+ driver = to_i2c_driver(dev->driver);
+
if (!client->irq) {
int irq = -ENOENT;
@@ -993,9 +995,11 @@ static int i2c_device_probe(struct device *dev)
} else if (dev->of_node) {
irq = of_irq_get_byname(dev->of_node, "irq");
if (irq == -EINVAL || irq == -ENODATA)
- irq = of_irq_get(dev->of_node, 0);
+ irq = of_irq_get(dev->of_node,
+ driver->irq_index);
} else if (ACPI_COMPANION(dev)) {
- irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0);
+ irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev),
+ driver->irq_index);
}
if (irq == -EPROBE_DEFER)
return irq;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 369ebfa..a5ffe29 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -212,6 +212,9 @@ struct i2c_driver {
int (*detect)(struct i2c_client *, struct i2c_board_info *);
const unsigned short *address_list;
struct list_head clients;
+
+ /* IRQ index for retreiving irq from ACPI resources */
+ int irq_index;
};
#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
--
2.9.3
prev parent reply other threads:[~2017-03-10 23:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 23:57 [PATCH v2 1/3] i2c: core: Allow getting acpi info by index Hans de Goede
2017-03-10 23:57 ` [PATCH v2 2/3] i2c: core: Add new i2c_acpi_new_device helper function Hans de Goede
2017-03-10 23:57 ` Hans de Goede [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170310235703.29984-3-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=linux-i2c@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).