Skip to content

Commit ddfebb7

Browse files
committed
ACPI: scan: Reduce code duplication related to fixed event devices
Move duplicate fixed event device registration code from acpi_bus_scan_fixed() into a new function called acpi_bus_add_fixed_device_object() and make acpi_bus_scan_fixed() invoke that function as needed. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/1916860.atdPhlSkOF@rafael.j.wysocki
1 parent ab06eb9 commit ddfebb7

1 file changed

Lines changed: 17 additions & 25 deletions

File tree

drivers/acpi/scan.c

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,37 +2759,29 @@ int acpi_bus_register_early_device(int type)
27592759
}
27602760
EXPORT_SYMBOL_GPL(acpi_bus_register_early_device);
27612761

2762-
static void acpi_bus_scan_fixed(void)
2762+
static void acpi_bus_add_fixed_device_object(enum acpi_bus_device_type type)
27632763
{
2764-
if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) {
2765-
struct acpi_device *adev = NULL;
2764+
struct acpi_device *adev = NULL;
27662765

2767-
acpi_add_single_object(&adev, NULL, ACPI_BUS_TYPE_POWER_BUTTON,
2768-
false);
2769-
if (adev) {
2770-
adev->flags.match_driver = true;
2771-
if (device_attach(&adev->dev) >= 0)
2772-
device_init_wakeup(&adev->dev, true);
2773-
else
2774-
dev_dbg(&adev->dev, "No driver\n");
2766+
acpi_add_single_object(&adev, NULL, type, false);
2767+
if (adev) {
2768+
adev->flags.match_driver = true;
2769+
if (device_attach(&adev->dev) >= 0)
2770+
device_init_wakeup(&adev->dev, true);
2771+
else
2772+
dev_dbg(&adev->dev, "No driver\n");
27752773

2776-
acpi_default_enumeration(adev);
2777-
}
2774+
acpi_default_enumeration(adev);
27782775
}
2776+
}
27792777

2780-
if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON)) {
2781-
struct acpi_device *adev = NULL;
2782-
2783-
acpi_add_single_object(&adev, NULL, ACPI_BUS_TYPE_SLEEP_BUTTON,
2784-
false);
2785-
if (adev) {
2786-
adev->flags.match_driver = true;
2787-
if (device_attach(&adev->dev) < 0)
2788-
dev_dbg(&adev->dev, "No driver\n");
2778+
static void acpi_bus_scan_fixed(void)
2779+
{
2780+
if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON))
2781+
acpi_bus_add_fixed_device_object(ACPI_BUS_TYPE_POWER_BUTTON);
27892782

2790-
acpi_default_enumeration(adev);
2791-
}
2792-
}
2783+
if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON))
2784+
acpi_bus_add_fixed_device_object(ACPI_BUS_TYPE_SLEEP_BUTTON);
27932785
}
27942786

27952787
static void __init acpi_get_spcr_uart_addr(void)

0 commit comments

Comments
 (0)