diff options
author | Hans de Goede <hdegoede@redhat.com> | 2024-11-04 21:08:46 +0100 |
---|---|---|
committer | Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> | 2024-11-06 15:15:46 +0200 |
commit | 01fbfcb3acbb2e4fd34bf36a87c75299a85a0cf9 (patch) | |
tree | a4f5cdc5e1a0dbbdda286c6f153481ff54b250ef /drivers/platform/x86/x86-android-tablets/core.c | |
parent | 44ed58e57984d0fb26d1e267deb9d83a1a071dfe (diff) | |
download | lwn-01fbfcb3acbb2e4fd34bf36a87c75299a85a0cf9.tar.gz lwn-01fbfcb3acbb2e4fd34bf36a87c75299a85a0cf9.zip |
platform/x86: x86-android-tablets: Add get_i2c_adap_by_handle() helper
Add get_i2c_adap_by_handle() helper function, this is a preparation patch
for adding support for getting i2c_adapter-s by PCI parent devname().
Suggested-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20241104200848.58693-2-hdegoede@redhat.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Diffstat (limited to 'drivers/platform/x86/x86-android-tablets/core.c')
-rw-r--r-- | drivers/platform/x86/x86-android-tablets/core.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c index 30dd845b543e..2848f651e00b 100644 --- a/drivers/platform/x86/x86-android-tablets/core.c +++ b/drivers/platform/x86/x86-android-tablets/core.c @@ -155,26 +155,33 @@ static struct gpiod_lookup_table * const *gpiod_lookup_tables; static const struct software_node *bat_swnode; static void (*exit_handler)(void); +static struct i2c_adapter * +get_i2c_adap_by_handle(const struct x86_i2c_client_info *client_info) +{ + acpi_handle handle; + acpi_status status; + + status = acpi_get_handle(NULL, client_info->adapter_path, &handle); + if (ACPI_FAILURE(status)) { + pr_err("Error could not get %s handle\n", client_info->adapter_path); + return NULL; + } + + return i2c_acpi_find_adapter_by_handle(handle); +} + static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info, int idx) { const struct x86_i2c_client_info *client_info = &dev_info->i2c_client_info[idx]; struct i2c_board_info board_info = client_info->board_info; struct i2c_adapter *adap; - acpi_handle handle; - acpi_status status; board_info.irq = x86_acpi_irq_helper_get(&client_info->irq_data); if (board_info.irq < 0) return board_info.irq; - status = acpi_get_handle(NULL, client_info->adapter_path, &handle); - if (ACPI_FAILURE(status)) { - pr_err("Error could not get %s handle\n", client_info->adapter_path); - return -ENODEV; - } - - adap = i2c_acpi_find_adapter_by_handle(handle); + adap = get_i2c_adap_by_handle(client_info); if (!adap) { pr_err("error could not get %s adapter\n", client_info->adapter_path); return -ENODEV; |