ACPI: glue: Use acpi_device_adr() in acpi_find_child_device()
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
@@ -113,13 +113,10 @@ struct acpi_device *acpi_find_child_devireturn 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) {
Quoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Instead of evaluating
_ADRinacpi_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
Rafael J. Wysocki
maintainerQuoted 14 lines · Andy Shevchenko
Quoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Instead of evaluating
_ADRinacpi_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.
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_addresis the address value andadev->pnp.type.bus_addressis a flag that is set to 1 when_ADRis 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