Skip to content

Commit

Permalink
i2c: core: Allow getting ACPI info by index
Browse files Browse the repository at this point in the history
Modify struct i2c_acpi_lookup and i2c_acpi_fill_info() to allow
using them to get the info from a certain index in the ACPI-resource
list rather then taking the first I2cSerialBus resource.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
  • Loading branch information
Hans de Goede authored and Wolfram Sang committed Apr 16, 2017
1 parent 97da385 commit 417f784
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ struct i2c_acpi_lookup {
acpi_handle adapter_handle;
acpi_handle device_handle;
acpi_handle search_handle;
int n;
int index;
u32 speed;
u32 min_speed;
};
Expand All @@ -130,6 +132,9 @@ static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data)
if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C)
return 1;

if (lookup->index != -1 && lookup->n++ != lookup->index)
return 1;

status = acpi_get_handle(lookup->device_handle,
sb->resource_source.string_ptr,
&lookup->adapter_handle);
Expand Down Expand Up @@ -182,6 +187,7 @@ static int i2c_acpi_get_info(struct acpi_device *adev,

memset(&lookup, 0, sizeof(lookup));
lookup.info = info;
lookup.index = -1;

ret = i2c_acpi_do_lookup(adev, &lookup);
if (ret)
Expand Down Expand Up @@ -328,6 +334,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev)
lookup.search_handle = ACPI_HANDLE(dev);
lookup.min_speed = UINT_MAX;
lookup.info = &dummy;
lookup.index = -1;

status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
I2C_ACPI_MAX_SCAN_DEPTH,
Expand Down

0 comments on commit 417f784

Please sign in to comment.