Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+12 -11
+12 -11
drivers/xen/xen-acpi-pad.c
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/types.h> 13 13 #include <linux/acpi.h> 14 + #include <linux/platform_device.h> 14 15 #include <xen/xen.h> 15 16 #include <xen/interface/version.h> 16 17 #include <xen/xen-ops.h> ··· 108 107 } 109 108 } 110 109 111 - static int acpi_pad_add(struct acpi_device *device) 110 + static int acpi_pad_probe(struct platform_device *pdev) 112 111 { 112 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 113 113 acpi_status status; 114 114 115 115 strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME); ··· 124 122 return 0; 125 123 } 126 124 127 - static void acpi_pad_remove(struct acpi_device *device) 125 + static void acpi_pad_remove(struct platform_device *pdev) 128 126 { 129 127 mutex_lock(&xen_cpu_lock); 130 128 xen_acpi_pad_idle_cpus(0); 131 129 mutex_unlock(&xen_cpu_lock); 132 130 133 - acpi_remove_notify_handler(device->handle, 131 + acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), 134 132 ACPI_DEVICE_NOTIFY, acpi_pad_notify); 135 133 } 136 134 ··· 139 137 {"", 0}, 140 138 }; 141 139 142 - static struct acpi_driver acpi_pad_driver = { 143 - .name = "processor_aggregator", 144 - .class = ACPI_PROCESSOR_AGGREGATOR_CLASS, 145 - .ids = pad_device_ids, 146 - .ops = { 147 - .add = acpi_pad_add, 148 - .remove = acpi_pad_remove, 140 + static struct platform_driver acpi_pad_driver = { 141 + .probe = acpi_pad_probe, 142 + .remove = acpi_pad_remove, 143 + .driver = { 144 + .name = "acpi_processor_aggregator", 145 + .acpi_match_table = pad_device_ids, 149 146 }, 150 147 }; 151 148 ··· 158 157 if (!xen_running_on_version_or_later(4, 2)) 159 158 return -ENODEV; 160 159 161 - return acpi_bus_register_driver(&acpi_pad_driver); 160 + return platform_driver_register(&acpi_pad_driver); 162 161 } 163 162 subsys_initcall(xen_acpi_pad_init);