aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-10-14 16:47:55 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-20 19:38:58 +0200
commit0a2d47aa32f0e972a136ddea15bddfdd9957e292 (patch)
tree471977541363f521ea54414b024fb49a15023753 /drivers/i2c
parentdriver core: Provide device_match_acpi_handle() helper (diff)
downloadlinux-dev-0a2d47aa32f0e972a136ddea15bddfdd9957e292.tar.xz
linux-dev-0a2d47aa32f0e972a136ddea15bddfdd9957e292.zip
i2c: acpi: Replace custom function with device_match_acpi_handle()
Since driver core provides a generic device_match_acpi_handle() we may replace the custom one with it. This unifies code to find an adapter with the similar one which finds a client. Acked-by: Wolfram Sang <wsa@kernel.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://lore.kernel.org/r/20211014134756.39092-2-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core-acpi.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 546cc935e035..80631f93ad2f 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -398,24 +398,20 @@ u32 i2c_acpi_find_bus_speed(struct device *dev)
}
EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);
-static int i2c_acpi_find_match_adapter(struct device *dev, const void *data)
-{
- struct i2c_adapter *adapter = i2c_verify_adapter(dev);
-
- if (!adapter)
- return 0;
-
- return ACPI_HANDLE(dev) == (acpi_handle)data;
-}
-
struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
{
+ struct i2c_adapter *adapter;
struct device *dev;
- dev = bus_find_device(&i2c_bus_type, NULL, handle,
- i2c_acpi_find_match_adapter);
+ dev = bus_find_device(&i2c_bus_type, NULL, handle, device_match_acpi_handle);
+ if (!dev)
+ return NULL;
+
+ adapter = i2c_verify_adapter(dev);
+ if (!adapter)
+ put_device(dev);
- return dev ? i2c_verify_adapter(dev) : NULL;
+ return adapter;
}
EXPORT_SYMBOL_GPL(i2c_acpi_find_adapter_by_handle);