Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+21 -37
+21 -37
drivers/acpi/scan.c
··· 2486 2486 } 2487 2487 EXPORT_SYMBOL_GPL(acpi_bus_register_early_device); 2488 2488 2489 - static int acpi_bus_scan_fixed(void) 2489 + static void acpi_bus_scan_fixed(void) 2490 2490 { 2491 - int result = 0; 2492 - 2493 - /* 2494 - * Enumerate all fixed-feature devices. 2495 - */ 2496 2491 if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) { 2497 - struct acpi_device *device = NULL; 2492 + struct acpi_device *adev = NULL; 2498 2493 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); 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 + } 2510 2503 } 2511 2504 2512 2505 if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON)) { 2513 - struct acpi_device *device = NULL; 2506 + struct acpi_device *adev = NULL; 2514 2507 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); 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 + } 2522 2515 } 2523 - 2524 - return result < 0 ? result : 0; 2525 2516 } 2526 2517 2527 2518 static void __init acpi_get_spcr_uart_addr(void) ··· 2592 2601 goto out; 2593 2602 2594 2603 /* Fixed feature devices do not exist on HW-reduced platform */ 2595 - if (!acpi_gbl_reduced_hardware) { 2596 - if (acpi_bus_scan_fixed()) { 2597 - acpi_detach_data(acpi_root->handle, 2598 - acpi_scan_drop_device); 2599 - acpi_device_del(acpi_root); 2600 - acpi_bus_put_acpi_device(acpi_root); 2601 - goto out; 2602 - } 2603 - } 2604 + if (!acpi_gbl_reduced_hardware) 2605 + acpi_bus_scan_fixed(); 2604 2606 2605 2607 acpi_turn_off_unused_power_resources(); 2606 2608