From f4203ec64e1155c07c5d95bddc62201af8598c67 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 15 Dec 2025 14:59:00 +0100 Subject: [PATCH] ACPI: tiny-power-button: Convert the driver to a platform one While binding drivers directly to struct acpi_device objects allows basic functionality to be provided, at least in the majority of cases, there are some problems with it, related to general consistency, sysfs layout, power management operation ordering, and code cleanliness. Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the ACPI tiny-power-button driver to a platform one. While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space. Signed-off-by: Rafael J. Wysocki [ rjw: White space fixup ] Link: https://patch.msgid.link/5629403.Sb9uPGUboI@rafael.j.wysocki Signed-off-by: Rafael J. Wysocki --- drivers/acpi/tiny-power-button.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/tiny-power-button.c b/drivers/acpi/tiny-power-button.c index 6353be6fec698..531e65b01bcbe 100644 --- a/drivers/acpi/tiny-power-button.c +++ b/drivers/acpi/tiny-power-button.c @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later +#include #include +#include #include -#include #include MODULE_AUTHOR("Josh Triplett"); @@ -35,8 +36,9 @@ static u32 acpi_tiny_power_button_event(void *not_used) return ACPI_INTERRUPT_HANDLED; } -static int acpi_tiny_power_button_add(struct acpi_device *device) +static int acpi_tiny_power_button_probe(struct platform_device *pdev) { + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); acpi_status status; if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { @@ -55,8 +57,10 @@ static int acpi_tiny_power_button_add(struct acpi_device *device) return 0; } -static void acpi_tiny_power_button_remove(struct acpi_device *device) +static void acpi_tiny_power_button_remove(struct platform_device *pdev) { + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); + if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, acpi_tiny_power_button_event); @@ -67,14 +71,13 @@ static void acpi_tiny_power_button_remove(struct acpi_device *device) acpi_os_wait_events_complete(); } -static struct acpi_driver acpi_tiny_power_button_driver = { - .name = "tiny-power-button", - .class = "tiny-power-button", - .ids = tiny_power_button_device_ids, - .ops = { - .add = acpi_tiny_power_button_add, - .remove = acpi_tiny_power_button_remove, +static struct platform_driver acpi_tiny_power_button_driver = { + .probe = acpi_tiny_power_button_probe, + .remove = acpi_tiny_power_button_remove, + .driver = { + .name = "acpi-tiny-power-button", + .acpi_match_table = tiny_power_button_device_ids, }, }; -module_acpi_driver(acpi_tiny_power_button_driver); +module_platform_driver(acpi_tiny_power_button_driver); -- 2.47.3