summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2025-12-15 16:54:17 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2025-12-26 17:08:57 +0300
commitddfebb7537cb422eca26ebdc3fe3426b60582c25 (patch)
tree0f99e6355f3fe09f00791f9a715f6b568d62803d
parentab06eb9204010c61e754bf4e71ee6f554584714d (diff)
downloadlinux-ddfebb7537cb422eca26ebdc3fe3426b60582c25.tar.xz
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
-rw-r--r--drivers/acpi/scan.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index da4da565f257..0ae36ab7b6ee 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2759,37 +2759,29 @@ int acpi_bus_register_early_device(int type)
}
EXPORT_SYMBOL_GPL(acpi_bus_register_early_device);
-static void acpi_bus_scan_fixed(void)
+static void acpi_bus_add_fixed_device_object(enum acpi_bus_device_type type)
{
- if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) {
- struct acpi_device *adev = NULL;
+ 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");
+ acpi_add_single_object(&adev, NULL, type, 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");
- acpi_default_enumeration(adev);
- }
+ acpi_default_enumeration(adev);
}
+}
- if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON)) {
- 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");
+static void acpi_bus_scan_fixed(void)
+{
+ if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON))
+ acpi_bus_add_fixed_device_object(ACPI_BUS_TYPE_POWER_BUTTON);
- acpi_default_enumeration(adev);
- }
- }
+ if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON))
+ acpi_bus_add_fixed_device_object(ACPI_BUS_TYPE_SLEEP_BUTTON);
}
static void __init acpi_get_spcr_uart_addr(void)