Skip to content

Commit 112b2f9

Browse files
committed
ACPI: PAD: xen: Convert to a platform driver
In all cases in which a struct acpi_driver is used for binding a driver to an ACPI device object, a corresponding platform device is created by the ACPI core and that device is regarded as a proper representation of underlying hardware. Accordingly, a struct platform_driver should be used by driver code to bind to that device. There are multiple reasons why drivers should not bind directly to ACPI device objects [1]. Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the Xen ACPI processor aggregator device (PAD) 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. Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/8683270.T7Z3S40VBb@rafael.j.wysocki
1 parent a56a658 commit 112b2f9

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

drivers/xen/xen-acpi-pad.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/kernel.h>
1212
#include <linux/types.h>
1313
#include <linux/acpi.h>
14+
#include <linux/platform_device.h>
1415
#include <xen/xen.h>
1516
#include <xen/interface/version.h>
1617
#include <xen/xen-ops.h>
@@ -107,8 +108,9 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
107108
}
108109
}
109110

110-
static int acpi_pad_add(struct acpi_device *device)
111+
static int acpi_pad_probe(struct platform_device *pdev)
111112
{
113+
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
112114
acpi_status status;
113115

114116
strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
@@ -122,13 +124,13 @@ static int acpi_pad_add(struct acpi_device *device)
122124
return 0;
123125
}
124126

125-
static void acpi_pad_remove(struct acpi_device *device)
127+
static void acpi_pad_remove(struct platform_device *pdev)
126128
{
127129
mutex_lock(&xen_cpu_lock);
128130
xen_acpi_pad_idle_cpus(0);
129131
mutex_unlock(&xen_cpu_lock);
130132

131-
acpi_remove_notify_handler(device->handle,
133+
acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev),
132134
ACPI_DEVICE_NOTIFY, acpi_pad_notify);
133135
}
134136

@@ -137,13 +139,12 @@ static const struct acpi_device_id pad_device_ids[] = {
137139
{"", 0},
138140
};
139141

140-
static struct acpi_driver acpi_pad_driver = {
141-
.name = "processor_aggregator",
142-
.class = ACPI_PROCESSOR_AGGREGATOR_CLASS,
143-
.ids = pad_device_ids,
144-
.ops = {
145-
.add = acpi_pad_add,
146-
.remove = acpi_pad_remove,
142+
static struct platform_driver acpi_pad_driver = {
143+
.probe = acpi_pad_probe,
144+
.remove = acpi_pad_remove,
145+
.driver = {
146+
.name = "acpi_processor_aggregator",
147+
.acpi_match_table = pad_device_ids,
147148
},
148149
};
149150

@@ -157,6 +158,6 @@ static int __init xen_acpi_pad_init(void)
157158
if (!xen_running_on_version_or_later(4, 2))
158159
return -ENODEV;
159160

160-
return acpi_bus_register_driver(&acpi_pad_driver);
161+
return platform_driver_register(&acpi_pad_driver);
161162
}
162163
subsys_initcall(xen_acpi_pad_init);

0 commit comments

Comments
 (0)