Skip to contentSkip to conversation

ACPI: glue: Use acpi_device_adr() in acpi_find_child_device()

PATCH In review Rafael J. Wysocki 3 participants 4 messages Oct 27, 2021 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: glue: Use acpi_device_adr() in acpi_find_child_device()

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

Instead of evaluating _ADR in acpi_find_child_device(), use the observation that it has already been evaluated and the value returned by it has been stored in the pnp.type.bus_address field of the ACPI device object at hand.

---

Note that the patch at

https://patchwork.kernel.org/project/linux-acpi/patch/2223516.ElGaqSPkdT@kreacher/

will have an effect of this, so I'm going to prioritize the current patch over the one above.

---
 drivers/acpi/glue.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/acpi/glue.c +2 -5
Index: linux-pm/drivers/acpi/glue.c
===================================================================
@@ -113,13 +113,10 @@ struct acpi_device *acpi_find_child_devi
 		return NULL;
 
 	list_for_each_entry(adev, &parent->children, node) {
-		unsigned long long addr;
-		acpi_status status;
+		acpi_bus_address addr = acpi_device_adr(adev);
 		int score;
 
-		status = acpi_evaluate_integer(adev->handle, METHOD_NAME__ADR,
-					       NULL, &addr);
-		if (ACPI_FAILURE(status) || addr != address)
+		if (!adev->pnp.type.bus_address || addr != address)
 			continue;
 
 		if (!ret) {
#1 lore raw
Quoted 6 lines · Rafael J. Wysocki

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

Instead of evaluating _ADR in acpi_find_child_device(), use the observation that it has already been evaluated and the value returned by it has been stored in the pnp.type.bus_address field of the ACPI device object at hand.

...

drivers/acpi/glue.c struct acpi_device *acpi_find_child_devi · line 120

Quoted 8 lines
drivers/acpi/glue.c +2 -3
+		acpi_bus_address addr = acpi_device_adr(adev);
 		int score;
 
-		status = acpi_evaluate_integer(adev->handle, METHOD_NAME__ADR,
-					       NULL, &addr);
-		if (ACPI_FAILURE(status) || addr != address)
+		if (!adev->pnp.type.bus_address || addr != address)
 			continue;

I'm not sure I understand the new check, i.e. !adev->pnp.type.bus_address. IIUC _ADR == 0 is a valid value and children may have it like this.

I believe this change will break the working things (first comes to my mind is drivers/mfd/intel_quark_i2c_gpio.c).

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

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

Instead of evaluating _ADR in acpi_find_child_device(), use the observation that it has already been evaluated and the value returned by it has been stored in the pnp.type.bus_address field of the ACPI device object at hand.

...

Quoted 3 lines
+             acpi_bus_address addr = acpi_device_adr(adev);
              int score;
Quoted 7 lines

drivers/acpi/glue.c struct acpi_device *acpi_find_child_devi · line 120

Quoted 5 lines
drivers/acpi/glue.c +1 -3
-             status = acpi_evaluate_integer(adev->handle, METHOD_NAME__ADR,
-                                            NULL, &addr);
-             if (ACPI_FAILURE(status) || addr != address)
+             if (!adev->pnp.type.bus_address || addr != address)
                      continue;

I'm not sure I understand the new check, i.e. !adev->pnp.type.bus_address.

See acpi_set_pnp_ids().

adev->pnp.bus_addres is the address value and adev->pnp.type.bus_address is a flag that is set to 1 when _ADR is valid.

Quoted 1 line

IIUC _ADR == 0 is a valid value and children may have it like this.

That's true.

Quoted 2 lines

I believe this change will break the working things (first comes to my mind is drivers/mfd/intel_quark_i2c_gpio.c).

I don't think so.

#3 lore raw
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Andy Shevchenko

On Wed, Oct 27, 2021 at 06:59:06PM +0200, Rafael J. Wysocki wrote:

...

Quoted 6 lines

See acpi_set_pnp_ids().

adev->pnp.bus_addres is the address value and adev->pnp.type.bus_address is a flag that is set to 1 when _ADR is valid.

Quoted 8 lines
Quoted 1 line

IIUC _ADR == 0 is a valid value and children may have it like this.

That's true.

Quoted 2 lines

I believe this change will break the working things (first comes to my mind is drivers/mfd/intel_quark_i2c_gpio.c).

I don't think so.

With your explanation I see where my logic is wrong. Thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko