diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2020-12-14 23:32:44 +0300 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2020-12-17 19:51:49 +0300 |
commit | 0de7fb7c8687048299305529d17f6a1e98ae658c (patch) | |
tree | fa46b733c61fd7f3033c8bda6b2f92cde3421bae /drivers/acpi/scan.c | |
parent | 71da201f38dfb0c3a3d33bbe3168ea9112299dde (diff) | |
download | linux-0de7fb7c8687048299305529d17f6a1e98ae658c.tar.xz |
ACPI: scan: Avoid unnecessary second pass in acpi_bus_scan()
If there are no devices whose enumeration has been deferred after
the first pass in acpi_bus_scan(), the second pass is not necssary,
so avoid it with the help of a new static variable.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 00f1b09f15a4..28713741d6ee 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1910,6 +1910,8 @@ static void acpi_scan_dep_init(struct acpi_device *adev) mutex_unlock(&acpi_dep_list_lock); } +static bool acpi_bus_scan_second_pass; + static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep, struct acpi_device **adev_p) { @@ -1934,8 +1936,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep, if (type == ACPI_BUS_TYPE_DEVICE && check_dep) { u32 count = acpi_scan_check_dep(handle); /* Bail out if the number of recorded dependencies is not 0. */ - if (count > 0) + if (count > 0) { + acpi_bus_scan_second_pass = true; return AE_CTRL_DEPTH; + } } acpi_add_single_object(&device, handle, type, sta); @@ -2136,6 +2140,8 @@ int acpi_bus_scan(acpi_handle handle) { struct acpi_device *device = NULL; + acpi_bus_scan_second_pass = false; + /* Pass 1: Avoid enumerating devices with missing dependencies. */ if (ACPI_SUCCESS(acpi_bus_check_add(handle, true, &device))) @@ -2148,6 +2154,9 @@ int acpi_bus_scan(acpi_handle handle) acpi_bus_attach(device, true); + if (!acpi_bus_scan_second_pass) + return 0; + /* Pass 2: Enumerate all of the remaining devices. */ device = NULL; |