Skip to contentSkip to conversation

i2c: ACPI: Replace acpi_bus_get_device()

PATCH Applied Rafael J. Wysocki 5 participants 6 messages Feb 1, 2022 – Feb 7, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: ACPI: Replace acpi_bus_get_device()

From: Rafael J. Wysocki <[email protected]>

Replace acpi_bus_get_device() that is going to be dropped with acpi_fetch_acpi_dev().

No intentional functional impact.

---
 drivers/i2c/i2c-core-acpi.c |   17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/i2c/i2c-core-acpi.c +6 -11
Index: linux-pm/drivers/i2c/i2c-core-acpi.c
===================================================================
@@ -236,7 +236,8 @@ static int i2c_acpi_get_info(struct acpi
 		struct acpi_device *adapter_adev;
 
 		/* The adapter must be present */
-		if (acpi_bus_get_device(lookup.adapter_handle, &adapter_adev))
+		adapter_adev = acpi_fetch_acpi_dev(lookup.adapter_handle);
+		if (!adapter_adev)
 			return -ENODEV;
 		if (acpi_bus_get_status(adapter_adev) ||
 		    !adapter_adev->status.present)
@@ -275,13 +276,10 @@ static acpi_status i2c_acpi_add_device(a
 				       void *data, void **return_value)
 {
 	struct i2c_adapter *adapter = data;
-	struct acpi_device *adev;
+	struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
 	struct i2c_board_info info;
 
-	if (acpi_bus_get_device(handle, &adev))
-		return AE_OK;
-
-	if (i2c_acpi_get_info(adev, &info, adapter, NULL))
+	if (!adev || i2c_acpi_get_info(adev, &info, adapter, NULL))
 		return AE_OK;
 
 	i2c_acpi_register_device(adapter, adev, &info);
@@ -341,12 +339,9 @@ static acpi_status i2c_acpi_lookup_speed
 					   void *data, void **return_value)
 {
 	struct i2c_acpi_lookup *lookup = data;
-	struct acpi_device *adev;
-
-	if (acpi_bus_get_device(handle, &adev))
-		return AE_OK;
+	struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
 
-	if (i2c_acpi_do_lookup(adev, lookup))
+	if (!adev || i2c_acpi_do_lookup(adev, lookup))
 		return AE_OK;
 
 	if (lookup->search_handle != lookup->adapter_handle)
#1 lore raw
Quoted 6 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Replace acpi_bus_get_device() that is going to be dropped with acpi_fetch_acpi_dev().

No intentional functional impact.

...

drivers/i2c/i2c-core-acpi.c static acpi_status i2c_acpi_add_device(a · line 282

Quoted 1 line
drivers/i2c/i2c-core-acpi.c +1 -0
+	if (!adev || i2c_acpi_get_info(adev, &info, adapter, NULL))

AFAICS the !adev check is redundant since acpi_device_enumerated() does it.

Quoted 1 line

return AE_OK;

...

drivers/i2c/i2c-core-acpi.c static acpi_status i2c_acpi_lookup_speed · line 345

Quoted 5 lines
drivers/i2c/i2c-core-acpi.c +2 -1
+	struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
 
-	if (i2c_acpi_do_lookup(adev, lookup))
+	if (!adev || i2c_acpi_do_lookup(adev, lookup))
 		return AE_OK;

Here we need it indeed.
Dunno, if acpi_dev_ready_for_enumeration() can gain the check itself.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Replace acpi_bus_get_device() that is going to be dropped with acpi_fetch_acpi_dev().

Quoted 7 lines
Quoted 1 line

No intentional functional impact.

...

Quoted 1 line

+ if (!adev || i2c_acpi_get_info(adev, &info, adapter, NULL))

AFAICS the !adev check is redundant since acpi_device_enumerated() does it.

No.

acpi_device_enumerated() returns false if adev is NULL, so without this extra check i2c_acpi_get_info() will end up passing NULL to i2c_acpi_do_lookup().

Quoted 4 lines
Quoted 1 line
              return AE_OK;

...

Quoted 8 lines

drivers/i2c/i2c-core-acpi.c static acpi_status i2c_acpi_lookup_speed · line 345

Quoted 5 lines
drivers/i2c/i2c-core-acpi.c +2 -1
+     struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
 
-     if (i2c_acpi_do_lookup(adev, lookup))
+     if (!adev || i2c_acpi_do_lookup(adev, lookup))
              return AE_OK;

Here we need it indeed.
Dunno, if acpi_dev_ready_for_enumeration() can gain the check itself.

Well, acpi_bus_get_status() would need it too.

Reviewed-by
#3 lore raw
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Andy Shevchenko
Quoted 6 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Replace acpi_bus_get_device() that is going to be dropped with acpi_fetch_acpi_dev().

No intentional functional impact.

...

Quoted 1 line

+ if (!adev || i2c_acpi_get_info(adev, &info, adapter, NULL))

Quoted 7 lines
Quoted 1 line

AFAICS the !adev check is redundant since acpi_device_enumerated() does it.

No.

acpi_device_enumerated() returns false if adev is NULL, so without this extra check i2c_acpi_get_info() will end up passing NULL to i2c_acpi_do_lookup().

I see now.

The patch LGTM,

Quoted 14 lines
Quoted 4 lines
Quoted 1 line
              return AE_OK;

...

Quoted 8 lines

drivers/i2c/i2c-core-acpi.c static acpi_status i2c_acpi_lookup_speed · line 345

Quoted 5 lines
drivers/i2c/i2c-core-acpi.c +2 -1
+     struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
 
-     if (i2c_acpi_do_lookup(adev, lookup))
+     if (!adev || i2c_acpi_do_lookup(adev, lookup))
              return AE_OK;

Here we need it indeed.
Dunno, if acpi_dev_ready_for_enumeration() can gain the check itself.

Well, acpi_bus_get_status() would need it too.

Signature · 2 lines
With Best Regards,
Andy Shevchenko