From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>,
Wolfram Sang <wsa@the-dreams.de>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Sebastian Reichel <sre@kernel.org>
Cc: linux-acpi@vger.kernel.org, Takashi Iwai <tiwai@suse.de>,
linux-pm@vger.kernel.org
Subject: Re: [PATCH v3 3/4] i2c: core: Allow drivers to specify index for irq to get from of / ACPI
Date: Sun, 26 Mar 2017 15:15:35 +0300 [thread overview]
Message-ID: <1490530535.21738.31.camel@linux.intel.com> (raw)
In-Reply-To: <20170325135550.22509-4-hdegoede@redhat.com>
On Sat, 2017-03-25 at 14:55 +0100, Hans de Goede wrote:
> 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.
Just a side note / question: are we assuming that the index of
I2cSerialBus() resource and index of GpioInt() resource should be 1:1
mapped?
One nit below, and
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v2:
> -Actually also use the irq_index for of interrupts
> Changes in v3:
> -Add kernel doc for new i2c_driver irq_index member
> -Remove duplicate assignment of driver in i2c_device_probe
> ---
> drivers/i2c/i2c-core.c | 10 ++++++----
> include/linux/i2c.h | 4 ++++
> 2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 062b480..a7dfa6c 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -983,6 +983,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;
>
> @@ -992,9 +994,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;
> @@ -1005,8 +1009,6 @@ static int i2c_device_probe(struct device *dev)
> client->irq = irq;
> }
>
> - driver = to_i2c_driver(dev->driver);
> -
> /*
> * An I2C ID table is not mandatory, if and only if, a
> suitable Device
> * Tree match table entry is supplied for the probing device.
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index 369ebfa..79de1d1 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -149,6 +149,7 @@ enum i2c_alert_protocol {
> * @detect: Callback for device detection
> * @address_list: The I2C addresses to probe (for detect)
> * @clients: List of detected clients we created (for i2c-core use
> only)
> + * @irq_index: IRQ index for retreiving irq from OF/ACPI
> *
> * The driver.owner field should be set to the module owner of this
> driver.
> * The driver.name field should be set to the name of this driver.
> @@ -212,6 +213,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 OF/ACPI */
Since kernel doc in place the above is redundant.
> + int irq_index;
> };
> #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
>
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2017-03-26 12:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-25 13:55 [PATCH v3 0/4]: i2c-core improvements for complex ACPI-devices + cht-wc-fuel-gauge driver Hans de Goede
2017-03-25 13:55 ` [PATCH v3 1/4] i2c: core: Allow getting ACPI info by index Hans de Goede
2017-03-26 12:16 ` Andy Shevchenko
2017-03-25 13:55 ` [PATCH v3 2/4] i2c: core: Add new i2c_acpi_new_device helper function Hans de Goede
2017-03-25 13:55 ` [PATCH v3 3/4] i2c: core: Allow drivers to specify index for irq to get from of / ACPI Hans de Goede
2017-03-26 12:15 ` Andy Shevchenko [this message]
2017-03-26 15:07 ` Hans de Goede
2017-03-30 17:39 ` Hans de Goede
2017-03-30 20:39 ` Wolfram Sang
2017-03-31 10:03 ` Hans de Goede
2017-03-31 16:23 ` Wolfram Sang
2017-03-31 18:22 ` Hans de Goede
2017-03-31 19:54 ` Wolfram Sang
2017-03-31 20:13 ` Andy Shevchenko
2017-03-31 20:59 ` Hans de Goede
2017-03-31 21:19 ` Wolfram Sang
2017-04-01 16:33 ` Dmitry Torokhov
2017-04-02 12:17 ` Hans de Goede
2017-04-03 18:29 ` Dmitry Torokhov
2017-03-25 13:55 ` [PATCH v3 4/4] power: supply: Add driver for Cherry Trail Whiskey Cove PMIC Fuel Gauge Hans de Goede
2017-03-25 18:42 ` Sebastian Reichel
2017-03-26 8:56 ` Hans de Goede
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=1490530535.21738.31.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=sre@kernel.org \
--cc=tiwai@suse.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.