[PATCH v2 01/13] ACPI: Add a honor_deps flag to struct acpi_device

From: Hans de Goede
Date: Sat Oct 09 2021 - 12:06:23 EST


At the moment dependencies by _DEP are mostly ignored by the ACPI code,
other then acpi_bus_scan() instantiating all devices without _DEP-s before
instantiating devices with _DEP-s.

The on exception to this is ACPI battery devices for which _DEP-s are fully
honored.

Now another case has come-up where we want to honor the _DEP-s.
In preparation for this add a new honor_deps flag to struct acpi_device
and move the existing battery special-case over to this flag.

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
drivers/acpi/bus.c | 4 ++--
drivers/acpi/scan.c | 4 ++++
include/acpi/acpi_bus.h | 1 +
3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index fa923a929224..7dd6262ca488 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -103,8 +103,8 @@ int acpi_bus_get_status(struct acpi_device *device)
return 0;
}

- /* Battery devices must have their deps met before calling _STA */
- if (acpi_device_is_battery(device) && device->dep_unmet) {
+ /* If honor_deps is set, the deps must be met before calling _STA */
+ if (device->honor_deps && device->dep_unmet) {
acpi_set_device_status(device, 0);
return 0;
}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 5b54c80b9d32..4e0a946b35ed 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1756,6 +1756,10 @@ static void acpi_scan_dep_init(struct acpi_device *adev)
{
struct acpi_dep_data *dep;

+ /* Always honor the deps for battery devices */
+ if (acpi_device_is_battery(adev))
+ adev->honor_deps = true;
+
list_for_each_entry(dep, &acpi_dep_list, node) {
if (dep->consumer == adev->handle)
adev->dep_unmet++;
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 13d93371790e..0ba344a5f4f8 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -381,6 +381,7 @@ struct acpi_device {
struct device dev;
unsigned int physical_node_count;
unsigned int dep_unmet;
+ bool honor_deps;
struct list_head physical_node_list;
struct mutex physical_node_lock;
void (*remove)(struct acpi_device *);
--
2.31.1