ACPI: scan: Rearrange dep_unmet initialization
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 10 May 2021 17:53:18 +0000 (19:53 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 17 May 2021 14:26:25 +0000 (16:26 +0200)
commit6d27975851b134be8d2a170437210c9719e524aa
tree714295ab4417d8c59abc0cc1af12b5c429ee8bcb
parentd07f6ca923ea0927a1024dfccafc5b53b61cfecc
ACPI: scan: Rearrange dep_unmet initialization

The dep_unmet field in struct acpi_device is used to store the
number of unresolved _DEP dependencies (that is, operation region
dependencies for which there are no drivers present) for the ACPI
device object represented by it.

That field is initialized to 1 for all ACPI device objects in
acpi_add_single_object(), via acpi_init_device_object(), so as to
avoid evaluating _STA prematurely for battery device objects in
acpi_scan_init_status(), and it is "fixed up" in acpi_bus_check_add()
after the acpi_add_single_object() called by it has returned.

This is not particularly straightforward and causes dep_unmet to
remain 1 for device objects without dependencies created by invoking
acpi_add_single_object() directly, outside acpi_bus_check_add().

For this reason, rearrange acpi_add_single_object() to initialize
dep_unmet completely before calling acpi_scan_init_status(), which
requires passing one extra bool argument to it, and update all of
its callers accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
drivers/acpi/scan.c