public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"Linux PM" <linux-pm@vger.kernel.org>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Armin Wolf" <w_armin@gmx.de>
Subject: [PATCH v2 02/10] ACPI: scan: Reduce code duplication related to fixed event devices
Date: Mon, 15 Dec 2025 14:54:17 +0100	[thread overview]
Message-ID: <1916860.atdPhlSkOF@rafael.j.wysocki> (raw)
In-Reply-To: <2685338.Lt9SDvczpP@rafael.j.wysocki>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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>
---

v1 -> v2: No changes

---
 drivers/acpi/scan.c |   42 +++++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2754,37 +2754,29 @@ int acpi_bus_register_early_device(int t
 }
 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)




  parent reply	other threads:[~2025-12-15 14:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 13:50 [PATCH v2 00/10] ACPI: Convert button and battery drivers to platform ones Rafael J. Wysocki
2025-12-15 13:52 ` [PATCH v2 01/10] ACPI: scan: Register platform devices for fixed event buttons Rafael J. Wysocki
2025-12-15 13:54 ` Rafael J. Wysocki [this message]
2025-12-15 13:55 ` [PATCH v2 03/10] ACPI: button: Adjust event notification routines Rafael J. Wysocki
2025-12-15 13:57 ` [PATCH v2 04/10] ACPI: button: Convert the driver to a platform one Rafael J. Wysocki
2025-12-15 13:59 ` [PATCH v2 05/10] ACPI: tiny-power-button: " Rafael J. Wysocki
2025-12-15 14:00 ` [PATCH v2 06/10] ACPI: scan: Do not bind ACPI drivers to fixed event buttons Rafael J. Wysocki
2025-12-15 14:00 ` [PATCH v2 07/10] ACPI: scan: Do not mark button ACPI devices as wakeup-capable Rafael J. Wysocki
2025-12-15 14:01 ` [PATCH v2 08/10] ACPI: battery: Adjust event notification routine Rafael J. Wysocki
2025-12-15 14:02 ` [PATCH v2 09/10] ACPI: battery: Reduce code duplication related to cleanup Rafael J. Wysocki
2025-12-15 14:03 ` [PATCH v2 10/10] ACPI: battery: Convert the driver to a platform one Rafael J. Wysocki
2025-12-15 14:46 ` [PATCH v2 00/10] ACPI: Convert button and battery drivers to platform ones Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1916860.atdPhlSkOF@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=w_armin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox