From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Wolfram Sang <wsa@the-dreams.de>,
Jonathan Cameron <jic23@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
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: [PATCH 4/9] i2c: acpi: Allow get info by index in i2c_acpi_get_info()
Date: Sun, 20 May 2018 15:28:52 +0200 [thread overview]
Message-ID: <20180520132857.8103-5-hdegoede@redhat.com> (raw)
In-Reply-To: <20180520132857.8103-1-hdegoede@redhat.com>
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
For some devices we need to get info based on index. As a preparation of
support such, slightly modify i2c_acpi_get_info() helper.
While here, assume that interrupt resources are provided in the same amount
with 1:1 mapping to serial bus resources. This will not affect existing
behaviour because only first resource of each type is considered.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/i2c/i2c-core-acpi.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 7b1b0aeced36..75352b3744e5 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -129,17 +129,19 @@ static int i2c_acpi_do_lookup(struct acpi_device *adev,
static int i2c_acpi_get_info(struct acpi_device *adev,
struct i2c_board_info *info,
+ int index,
struct i2c_adapter *adapter,
acpi_handle *adapter_handle)
{
struct list_head resource_list;
struct resource_entry *entry;
struct i2c_acpi_lookup lookup;
+ unsigned int n;
int ret;
memset(&lookup, 0, sizeof(lookup));
lookup.info = info;
- lookup.index = -1;
+ lookup.index = index;
ret = i2c_acpi_do_lookup(adev, &lookup);
if (ret)
@@ -170,10 +172,13 @@ static int i2c_acpi_get_info(struct acpi_device *adev,
if (ret < 0)
return -EINVAL;
+ n = 0;
resource_list_for_each_entry(entry, &resource_list) {
if (resource_type(entry->res) == IORESOURCE_IRQ) {
- info->irq = entry->res->start;
- break;
+ if (index == -1 || n++ == index) {
+ info->irq = entry->res->start;
+ break;
+ }
}
}
@@ -210,7 +215,7 @@ static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level,
if (acpi_bus_get_device(handle, &adev))
return AE_OK;
- if (i2c_acpi_get_info(adev, &info, adapter, NULL))
+ if (i2c_acpi_get_info(adev, &info, -1, adapter, NULL))
return AE_OK;
i2c_acpi_register_device(adapter, adev, &info);
@@ -356,7 +361,7 @@ static int i2c_acpi_notify(struct notifier_block *nb, unsigned long value,
switch (value) {
case ACPI_RECONFIG_DEVICE_ADD:
- if (i2c_acpi_get_info(adev, &info, NULL, &adapter_handle))
+ if (i2c_acpi_get_info(adev, &info, -1, NULL, &adapter_handle))
break;
adapter = i2c_acpi_find_adapter_by_handle(adapter_handle);
--
2.17.0
next prev parent reply other threads:[~2018-05-20 13:28 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
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 ` Hans de Goede [this message]
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=20180520132857.8103-5-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andriy.shevchenko@linux.intel.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).