[RFC,22/57] drivers: i2c: Use generic helper to match device by acpi_dev
diff mbox series

Message ID 1559577023-558-23-git-send-email-suzuki.poulose@arm.com
State New
Headers show
Series
  • [RFC,01/57] drivers: s390/cio: Use driver_for_each_device
Related show

Commit Message

Suzuki K Poulose June 3, 2019, 3:49 p.m. UTC
Switch to the generic helper to match device by acpi_dev.

Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
cc: linux-i2c@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/i2c/i2c-core-acpi.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Comments

Mika Westerberg June 4, 2019, 9:27 a.m. UTC | #1
On Mon, Jun 03, 2019 at 04:49:48PM +0100, Suzuki K Poulose wrote:
> Switch to the generic helper to match device by acpi_dev.

It would be nice if you had Cc'd actual implementation of
device_match_acpi_dev() as well but if it looks like
i2c_acpi_find_match_device() then this is fine by me,

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Wolfram Sang June 6, 2019, 8:03 p.m. UTC | #2
> -	dev = bus_find_device(&i2c_bus_type, NULL, adev,
> -			      i2c_acpi_find_match_device);
> +	dev = bus_find_device(&i2c_bus_type, NULL, adev, device_match_acpi_dev);

In general, this looks like a nice cleanup which I am in favour of.
However, I didn't understand why ACPI uses bus_find_device() but OF has
a seperate helper bus_find_device_by_of_node(). Why this inconsistency
of having a seperate helper here and not there?
Suzuki K Poulose June 10, 2019, 12:49 p.m. UTC | #3
Hi,

On 06/06/2019 21:03, Wolfram Sang wrote:
> 
>> -	dev = bus_find_device(&i2c_bus_type, NULL, adev,
>> -			      i2c_acpi_find_match_device);
>> +	dev = bus_find_device(&i2c_bus_type, NULL, adev, device_match_acpi_dev);
> 
> In general, this looks like a nice cleanup which I am in favour of.
> However, I didn't understand why ACPI uses bus_find_device() but OF has
> a seperate helper bus_find_device_by_of_node(). Why this inconsistency
> of having a seperate helper here and not there?

This was skipped purposefully due to the header file dependency issues with
adding "acpi_bus.h" to linux/device.h, which kind of creates a circular
dependency for adding "struct acpi_device" to the prototype.

However, I think I have found a way to solve that and include that in
the next version.

Thanks
Suzuki

Patch
diff mbox series

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index d840955..e28165b 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -328,11 +328,6 @@  static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
 	return ACPI_HANDLE(dev) == (acpi_handle)data;
 }
 
-static int i2c_acpi_find_match_device(struct device *dev, void *data)
-{
-	return ACPI_COMPANION(dev) == data;
-}
-
 static struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
 {
 	struct device *dev;
@@ -346,8 +341,7 @@  static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev)
 {
 	struct device *dev;
 
-	dev = bus_find_device(&i2c_bus_type, NULL, adev,
-			      i2c_acpi_find_match_device);
+	dev = bus_find_device(&i2c_bus_type, NULL, adev, device_match_acpi_dev);
 	return dev ? i2c_verify_client(dev) : NULL;
 }