Skip to content

Commit 681e718

Browse files
committed
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>
1 parent b6c55b1 commit 681e718

File tree

1 file changed

+23
-39
lines changed

1 file changed

+23
-39
lines changed

drivers/acpi/scan.c

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,42 +2486,33 @@ int acpi_bus_register_early_device(int type)
24862486
}
24872487
EXPORT_SYMBOL_GPL(acpi_bus_register_early_device);
24882488

2489-
static int acpi_bus_scan_fixed(void)
2489+
static void acpi_bus_scan_fixed(void)
24902490
{
2491-
int result = 0;
2492-
2493-
/*
2494-
* Enumerate all fixed-feature devices.
2495-
*/
24962491
if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) {
2497-
struct acpi_device *device = NULL;
2498-
2499-
result = acpi_add_single_object(&device, NULL,
2500-
ACPI_BUS_TYPE_POWER_BUTTON, false);
2501-
if (result)
2502-
return result;
2503-
2504-
device->flags.match_driver = true;
2505-
result = device_attach(&device->dev);
2506-
if (result < 0)
2507-
return result;
2508-
2509-
device_init_wakeup(&device->dev, true);
2492+
struct acpi_device *adev = NULL;
2493+
2494+
acpi_add_single_object(&adev, NULL, ACPI_BUS_TYPE_POWER_BUTTON,
2495+
false);
2496+
if (adev) {
2497+
adev->flags.match_driver = true;
2498+
if (device_attach(&adev->dev) >= 0)
2499+
device_init_wakeup(&adev->dev, true);
2500+
else
2501+
dev_dbg(&adev->dev, "No driver\n");
2502+
}
25102503
}
25112504

25122505
if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON)) {
2513-
struct acpi_device *device = NULL;
2514-
2515-
result = acpi_add_single_object(&device, NULL,
2516-
ACPI_BUS_TYPE_SLEEP_BUTTON, false);
2517-
if (result)
2518-
return result;
2519-
2520-
device->flags.match_driver = true;
2521-
result = device_attach(&device->dev);
2506+
struct acpi_device *adev = NULL;
2507+
2508+
acpi_add_single_object(&adev, NULL, ACPI_BUS_TYPE_SLEEP_BUTTON,
2509+
false);
2510+
if (adev) {
2511+
adev->flags.match_driver = true;
2512+
if (device_attach(&adev->dev) < 0)
2513+
dev_dbg(&adev->dev, "No driver\n");
2514+
}
25222515
}
2523-
2524-
return result < 0 ? result : 0;
25252516
}
25262517

25272518
static void __init acpi_get_spcr_uart_addr(void)
@@ -2601,15 +2592,8 @@ void __init acpi_scan_init(void)
26012592
goto out;
26022593

26032594
/* Fixed feature devices do not exist on HW-reduced platform */
2604-
if (!acpi_gbl_reduced_hardware) {
2605-
if (acpi_bus_scan_fixed()) {
2606-
acpi_detach_data(acpi_root->handle,
2607-
acpi_scan_drop_device);
2608-
acpi_device_del(acpi_root);
2609-
acpi_bus_put_acpi_device(acpi_root);
2610-
goto out;
2611-
}
2612-
}
2595+
if (!acpi_gbl_reduced_hardware)
2596+
acpi_bus_scan_fixed();
26132597

26142598
acpi_turn_off_unused_power_resources();
26152599

0 commit comments

Comments
 (0)