linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Wolfram Sang <wsa@the-dreams.de>,
	Jonathan Cameron <jic23@kernel.org>
Cc: linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org
Subject: Re: [PATCH 2/9] i2c: Allow specifying irq-index to be used in i2c_device_probe()
Date: Mon, 21 May 2018 12:07:24 +0300	[thread overview]
Message-ID: <77af193a6335f8f29278dd23365f8c619a2c6e5f.camel@linux.intel.com> (raw)
In-Reply-To: <20180520132857.8103-3-hdegoede@redhat.com>

On Sun, 2018-05-20 at 15:28 +0200, Hans de Goede wrote:
> Some types of interrupts are retrieved in i2c_device_probe() because
> getting them might fail with -EPROBE_DEFER.
> 
> So far we've always assumed the first IRQ (index 0) in the firmware-
> node
> is the one we want.
> 
> At least with ACPI enumerated i2c-clients in some cases the firmware-
> node
> is shared between multiple i2c-clients so we need to be able to
> specify
> the index rather then hardcoding it at 0.
> 
> This commit adds a new fwnode_irq_index member to i2c_board_info and
> i2c_client which allows specifying the index.
> 

FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

P.S. I would go with 'unsigned int' for the index.

> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/i2c/i2c-core-base.c | 7 +++++--
>  include/linux/i2c.h         | 5 +++++
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 1ba40bb2b966..ae3fda2c96a4 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -312,9 +312,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,
> +						 client-
> >fwnode_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),
> +						    client-
> >fwnode_irq_index);
>  		}
>  		if (irq == -EPROBE_DEFER)
>  			return irq;
> @@ -724,6 +726,7 @@ i2c_new_device(struct i2c_adapter *adap, struct
> i2c_board_info const *info)
>  	client->flags = info->flags;
>  	client->addr = info->addr;
>  
> +	client->fwnode_irq_index = info->fwnode_irq_index;
>  	client->irq = info->irq;
>  	if (!client->irq)
>  		client->irq = i2c_dev_irq_from_resources(info-
> >resources,
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index 44ad14e016b5..7f9506714a5e 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -316,6 +316,8 @@ struct i2c_driver {
>   *	generic enough to hide second-sourcing and compatible
> revisions.
>   * @adapter: manages the bus segment hosting this I2C device
>   * @dev: Driver model device node for the slave.
> + * @fwnode_irq_index: some devices share a single fwnode, this tells
> + *                    i2c_device_probe() to use the Nth irq from the
> fwnode
>   * @irq: indicates the IRQ generated by this device (if any)
>   * @detected: member of an i2c_driver.clients list or i2c-core's
>   *	userspace_devices list
> @@ -334,6 +336,7 @@ struct i2c_client {
>  	char name[I2C_NAME_SIZE];
>  	struct i2c_adapter *adapter;	/* the adapter we sit on	
> */
>  	struct device dev;		/* the device structure	
> 	*/
> +	int fwnode_irq_index;		/* index for irq lookup	
> 	*/
>  	int irq;			/* irq issued by device	
> 	*/
>  	struct list_head detected;
>  #if IS_ENABLED(CONFIG_I2C_SLAVE)
> @@ -400,6 +403,7 @@ static inline bool i2c_detect_slave_mode(struct
> device *dev) { return false; }
>   * @properties: additional device properties for the device
>   * @resources: resources associated with the device
>   * @num_resources: number of resources in the @resources array
> + * @fwnode_irq_index: stored in i2c_client.fwnode_irq_index
>   * @irq: stored in i2c_client.irq
>   *
>   * I2C doesn't actually support hardware probing, although
> controllers and
> @@ -425,6 +429,7 @@ struct i2c_board_info {
>  	const struct property_entry *properties;
>  	const struct resource *resources;
>  	unsigned int	num_resources;
> +	int		fwnode_irq_index;
>  	int		irq;
>  };
>  

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2018-05-21  9:07 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-20 13:28 [PATCH 0/9] ACPI/i2c Enumerate several instances out of one fwnode Hans de Goede
2018-05-20 13:28 ` [PATCH 1/9] ACPI: export __acpi_match_device and __acpi_device[_uevent]_modalias Hans de Goede
2018-05-20 13:28 ` [PATCH 2/9] i2c: Allow specifying irq-index to be used in i2c_device_probe() Hans de Goede
2018-05-21  9:07   ` Andy Shevchenko [this message]
2018-05-21  9:08     ` Andy Shevchenko
2018-05-20 13:28 ` [PATCH 3/9] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper Hans de Goede
2018-05-20 13:28 ` [PATCH 4/9] i2c: acpi: Allow get info by index in i2c_acpi_get_info() Hans de Goede
2018-05-20 13:28 ` [PATCH 5/9] i2c: acpi: Enumerate several instances out of one device Hans de Goede
2018-05-20 13:28 ` [PATCH 6/9] i2c: acpi: Add BSG1160 to i2c_acpi_multiple_devices_ids Hans de Goede
2018-05-20 13:28 ` [PATCH 7/9] iio: accel: bmc150: Add support for BSG1160 ACPI HID Hans de Goede
2018-05-20 13:28 ` [PATCH 8/9] iio: gyro: bmg160: " Hans de Goede
2018-05-20 13:28 ` [PATCH 9/9] iio: magnetometer: bmc150: " Hans de Goede
2018-05-20 16:23 ` [PATCH 0/9] ACPI/i2c Enumerate several instances out of one fwnode Jonathan Cameron
2018-05-21 13:19   ` Lars-Peter Clausen
2018-05-21  9:19 ` Andy Shevchenko
2018-05-21 12:34   ` Hans de Goede
2018-05-21 13:13     ` Andy Shevchenko
2018-05-21 13:31       ` Lars-Peter Clausen
2018-05-21 13:40         ` Hans de Goede
2018-05-21 13:44           ` Hans de Goede
2018-05-21 15:07             ` Lars-Peter Clausen
2018-05-21 19:12               ` Hans de Goede
2018-05-22  7:59                 ` Heikki Krogerus
2018-05-22 10:53                 ` Jonathan Cameron
2018-05-22 11:40                 ` Lars-Peter Clausen
2018-05-22 11:55                   ` Hans de Goede
2018-05-22 12:02                     ` Lars-Peter Clausen
2018-05-21 13:31       ` Hans de Goede
2018-05-24  8:55 ` Rafael J. Wysocki
2018-05-24  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=77af193a6335f8f29278dd23365f8c619a2c6e5f.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --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).