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>
This commit is contained in:
Andy Shevchenko 2021-10-14 16:47:55 +03:00 committed by Greg Kroah-Hartman
parent a164ff53cb
commit 0a2d47aa32
1 changed files with 9 additions and 13 deletions

View File

@ -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;
return dev ? i2c_verify_adapter(dev) : NULL;
adapter = i2c_verify_adapter(dev);
if (!adapter)
put_device(dev);
return adapter;
}
EXPORT_SYMBOL_GPL(i2c_acpi_find_adapter_by_handle);