diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2022-01-11 17:52:00 +0100 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2022-01-12 15:58:49 +0100 |
commit | 681e7187aef46f8d4e0fd0ddd2f888e3e5533cb2 (patch) | |
tree | c1c6699087391f4f377bdbf27634370d4baef3e7 /drivers/acpi | |
parent | b6c55b162bcee62c43c18e59f38a4590be543032 (diff) | |
download | linux-stable-681e7187aef46f8d4e0fd0ddd2f888e3e5533cb2.tar.gz linux-stable-681e7187aef46f8d4e0fd0ddd2f888e3e5533cb2.tar.bz2 linux-stable-681e7187aef46f8d4e0fd0ddd2f888e3e5533cb2.zip |
ACPI: scan: Simplify initialization of power and sleep buttons
It should be perfectly fine to use ACPI if the "fixed" power or sleep
buttons cannot be initialized. Moreover, running acpi_bus_scan()
successfully on ACPI_ROOT_OBJECT generally causes many devices to
be enumerated and probed, possibly including the entire PCI bus, so
unregistering acpi_root if the registration of the "fixed" buttons
fails is rather unhelpful.
For this reason, do not fail acpi_scan_init() when
acpi_bus_scan_fixed() fails and turn the latter into a void function.
While at it, drop the outdated and misleading comment from
acpi_bus_scan_fixed().
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/scan.c | 62 |
1 files changed, 23 insertions, 39 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 7e7417f4df22..81ee565f47cd 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2486,42 +2486,33 @@ int acpi_bus_register_early_device(int type) } EXPORT_SYMBOL_GPL(acpi_bus_register_early_device); -static int acpi_bus_scan_fixed(void) +static void acpi_bus_scan_fixed(void) { - int result = 0; - - /* - * Enumerate all fixed-feature devices. - */ if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) { - struct acpi_device *device = NULL; - - result = acpi_add_single_object(&device, NULL, - ACPI_BUS_TYPE_POWER_BUTTON, false); - if (result) - return result; - - device->flags.match_driver = true; - result = device_attach(&device->dev); - if (result < 0) - return result; - - device_init_wakeup(&device->dev, true); + struct acpi_device *adev = NULL; + + acpi_add_single_object(&adev, NULL, ACPI_BUS_TYPE_POWER_BUTTON, + false); + if (adev) { + adev->flags.match_driver = true; + if (device_attach(&adev->dev) >= 0) + device_init_wakeup(&adev->dev, true); + else + dev_dbg(&adev->dev, "No driver\n"); + } } if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON)) { - struct acpi_device *device = NULL; - - result = acpi_add_single_object(&device, NULL, - ACPI_BUS_TYPE_SLEEP_BUTTON, false); - if (result) - return result; - - device->flags.match_driver = true; - result = device_attach(&device->dev); + struct acpi_device *adev = NULL; + + acpi_add_single_object(&adev, NULL, ACPI_BUS_TYPE_SLEEP_BUTTON, + false); + if (adev) { + adev->flags.match_driver = true; + if (device_attach(&adev->dev) < 0) + dev_dbg(&adev->dev, "No driver\n"); + } } - - return result < 0 ? result : 0; } static void __init acpi_get_spcr_uart_addr(void) @@ -2601,15 +2592,8 @@ void __init acpi_scan_init(void) goto out; /* Fixed feature devices do not exist on HW-reduced platform */ - if (!acpi_gbl_reduced_hardware) { - if (acpi_bus_scan_fixed()) { - acpi_detach_data(acpi_root->handle, - acpi_scan_drop_device); - acpi_device_del(acpi_root); - acpi_bus_put_acpi_device(acpi_root); - goto out; - } - } + if (!acpi_gbl_reduced_hardware) + acpi_bus_scan_fixed(); acpi_turn_off_unused_power_resources(); |