Skip to content

Commit f4203ec

Browse files
committed
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 <rafael.j.wysocki@intel.com> [ rjw: White space fixup ] Link: https://patch.msgid.link/5629403.Sb9uPGUboI@rafael.j.wysocki Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 52d8640 commit f4203ec

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

drivers/acpi/tiny-power-button.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
2+
#include <linux/acpi.h>
23
#include <linux/module.h>
4+
#include <linux/platform_device.h>
35
#include <linux/sched/signal.h>
4-
#include <linux/acpi.h>
56
#include <acpi/button.h>
67

78
MODULE_AUTHOR("Josh Triplett");
@@ -35,8 +36,9 @@ static u32 acpi_tiny_power_button_event(void *not_used)
3536
return ACPI_INTERRUPT_HANDLED;
3637
}
3738

38-
static int acpi_tiny_power_button_add(struct acpi_device *device)
39+
static int acpi_tiny_power_button_probe(struct platform_device *pdev)
3940
{
41+
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
4042
acpi_status status;
4143

4244
if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) {
@@ -55,8 +57,10 @@ static int acpi_tiny_power_button_add(struct acpi_device *device)
5557
return 0;
5658
}
5759

58-
static void acpi_tiny_power_button_remove(struct acpi_device *device)
60+
static void acpi_tiny_power_button_remove(struct platform_device *pdev)
5961
{
62+
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
63+
6064
if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) {
6165
acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
6266
acpi_tiny_power_button_event);
@@ -67,14 +71,13 @@ static void acpi_tiny_power_button_remove(struct acpi_device *device)
6771
acpi_os_wait_events_complete();
6872
}
6973

70-
static struct acpi_driver acpi_tiny_power_button_driver = {
71-
.name = "tiny-power-button",
72-
.class = "tiny-power-button",
73-
.ids = tiny_power_button_device_ids,
74-
.ops = {
75-
.add = acpi_tiny_power_button_add,
76-
.remove = acpi_tiny_power_button_remove,
74+
static struct platform_driver acpi_tiny_power_button_driver = {
75+
.probe = acpi_tiny_power_button_probe,
76+
.remove = acpi_tiny_power_button_remove,
77+
.driver = {
78+
.name = "acpi-tiny-power-button",
79+
.acpi_match_table = tiny_power_button_device_ids,
7780
},
7881
};
7982

80-
module_acpi_driver(acpi_tiny_power_button_driver);
83+
module_platform_driver(acpi_tiny_power_button_driver);

0 commit comments

Comments
 (0)