[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <24192980.6Emhk5qWAg@rafael.j.wysocki>
Date: Tue, 09 Dec 2025 14:55:12 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Linux ACPI <linux-acpi@...r.kernel.org>
Cc: Hans de Goede <hdegoede@...hat.com>, LKML <linux-kernel@...r.kernel.org>,
Linux PM <linux-pm@...r.kernel.org>,
Thomas Weißschuh <linux@...ssschuh.net>,
Armin Wolf <w_armin@....de>
Subject:
[PATCH v1 05/10] ACPI: tiny-power-button: Convert the driver to a platform
one
From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
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 <rafael.j.wysocki@...el.com>
---
drivers/acpi/tiny-power-button.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
--- 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 <linux/acpi.h>
#include <linux/module.h>
+#include <linux/platform_device.h>
#include <linux/sched/signal.h>
-#include <linux/acpi.h>
#include <acpi/button.h>
MODULE_AUTHOR("Josh Triplett");
@@ -35,8 +36,9 @@ static u32 acpi_tiny_power_button_event(
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(st
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_remov
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);
Powered by blists - more mailing lists