Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
0a2d47aa a164ff53

+9 -13
+9 -13
drivers/i2c/i2c-core-acpi.c
··· 398 398 } 399 399 EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed); 400 400 401 - static int i2c_acpi_find_match_adapter(struct device *dev, const void *data) 402 - { 403 - struct i2c_adapter *adapter = i2c_verify_adapter(dev); 404 - 405 - if (!adapter) 406 - return 0; 407 - 408 - return ACPI_HANDLE(dev) == (acpi_handle)data; 409 - } 410 - 411 401 struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle) 412 402 { 403 + struct i2c_adapter *adapter; 413 404 struct device *dev; 414 405 415 - dev = bus_find_device(&i2c_bus_type, NULL, handle, 416 - i2c_acpi_find_match_adapter); 406 + dev = bus_find_device(&i2c_bus_type, NULL, handle, device_match_acpi_handle); 407 + if (!dev) 408 + return NULL; 417 409 418 - return dev ? i2c_verify_adapter(dev) : NULL; 410 + adapter = i2c_verify_adapter(dev); 411 + if (!adapter) 412 + put_device(dev); 413 + 414 + return adapter; 419 415 } 420 416 EXPORT_SYMBOL_GPL(i2c_acpi_find_adapter_by_handle); 421 417