[PATCH v1] ACPI: PAD: xen: Convert to a platform driver

Rafael J. Wysocki posted 1 patch 1 week, 2 days ago
Failed in applying to current master (apply log)
There is a newer version of this series
drivers/xen/xen-acpi-pad.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
[PATCH v1] ACPI: PAD: xen: Convert to a platform driver
Posted by Rafael J. Wysocki 1 week, 2 days ago
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

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>
---

Note that the original ACPI PAD driver has been a platform driver for
quite some time already.

---
 drivers/xen/xen-acpi-pad.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/xen/xen-acpi-pad.c b/drivers/xen/xen-acpi-pad.c
index ede69a5278d3..75a39862c1df 100644
--- a/drivers/xen/xen-acpi-pad.c
+++ b/drivers/xen/xen-acpi-pad.c
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/acpi.h>
+#include <linux/platform_device.h>
 #include <xen/xen.h>
 #include <xen/interface/version.h>
 #include <xen/xen-ops.h>
@@ -107,8 +108,9 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
 	}
 }
 
-static int acpi_pad_add(struct acpi_device *device)
+static int acpi_pad_probe(struct platform_device *pdev)
 {
+	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 	acpi_status status;
 
 	strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
@@ -122,13 +124,13 @@ static int acpi_pad_add(struct acpi_device *device)
 	return 0;
 }
 
-static void acpi_pad_remove(struct acpi_device *device)
+static void acpi_pad_remove(struct platform_device *pdev)
 {
 	mutex_lock(&xen_cpu_lock);
 	xen_acpi_pad_idle_cpus(0);
 	mutex_unlock(&xen_cpu_lock);
 
-	acpi_remove_notify_handler(device->handle,
+	acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev),
 		ACPI_DEVICE_NOTIFY, acpi_pad_notify);
 }
 
@@ -137,13 +139,12 @@ static const struct acpi_device_id pad_device_ids[] = {
 	{"", 0},
 };
 
-static struct acpi_driver acpi_pad_driver = {
-	.name = "processor_aggregator",
-	.class = ACPI_PROCESSOR_AGGREGATOR_CLASS,
-	.ids = pad_device_ids,
-	.ops = {
-		.add = acpi_pad_add,
-		.remove = acpi_pad_remove,
+static struct platform_driver acpi_pad_driver = {
+	.probe = acpi_pad_probe,
+	.remove = acpi_pad_remove,
+	.driver = {
+		.name = "acpi_processor_aggregator",
+		.acpi_match_table = pad_device_ids,
 	},
 };
 
@@ -157,6 +158,6 @@ static int __init xen_acpi_pad_init(void)
 	if (!xen_running_on_version_or_later(4, 2))
 		return -ENODEV;
 
-	return acpi_bus_register_driver(&acpi_pad_driver);
+	return platform_driver_register(&acpi_pad_driver);
 }
 subsys_initcall(xen_acpi_pad_init);
-- 
2.51.0
Re: [PATCH v1] ACPI: PAD: xen: Convert to a platform driver
Posted by Rafael J. Wysocki 3 days, 2 hours ago
On Sat, Mar 14, 2026 at 12:57 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> 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>

If there are any objections or concerns regarding this change, please
let me know.

In the absence of any, I'll queue it up for 7.1.

Thanks!

> ---
>
> Note that the original ACPI PAD driver has been a platform driver for
> quite some time already.
>
> ---
>  drivers/xen/xen-acpi-pad.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/xen/xen-acpi-pad.c b/drivers/xen/xen-acpi-pad.c
> index ede69a5278d3..75a39862c1df 100644
> --- a/drivers/xen/xen-acpi-pad.c
> +++ b/drivers/xen/xen-acpi-pad.c
> @@ -11,6 +11,7 @@
>  #include <linux/kernel.h>
>  #include <linux/types.h>
>  #include <linux/acpi.h>
> +#include <linux/platform_device.h>
>  #include <xen/xen.h>
>  #include <xen/interface/version.h>
>  #include <xen/xen-ops.h>
> @@ -107,8 +108,9 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
>         }
>  }
>
> -static int acpi_pad_add(struct acpi_device *device)
> +static int acpi_pad_probe(struct platform_device *pdev)
>  {
> +       struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
>         acpi_status status;
>
>         strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
> @@ -122,13 +124,13 @@ static int acpi_pad_add(struct acpi_device *device)
>         return 0;
>  }
>
> -static void acpi_pad_remove(struct acpi_device *device)
> +static void acpi_pad_remove(struct platform_device *pdev)
>  {
>         mutex_lock(&xen_cpu_lock);
>         xen_acpi_pad_idle_cpus(0);
>         mutex_unlock(&xen_cpu_lock);
>
> -       acpi_remove_notify_handler(device->handle,
> +       acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev),
>                 ACPI_DEVICE_NOTIFY, acpi_pad_notify);
>  }
>
> @@ -137,13 +139,12 @@ static const struct acpi_device_id pad_device_ids[] = {
>         {"", 0},
>  };
>
> -static struct acpi_driver acpi_pad_driver = {
> -       .name = "processor_aggregator",
> -       .class = ACPI_PROCESSOR_AGGREGATOR_CLASS,
> -       .ids = pad_device_ids,
> -       .ops = {
> -               .add = acpi_pad_add,
> -               .remove = acpi_pad_remove,
> +static struct platform_driver acpi_pad_driver = {
> +       .probe = acpi_pad_probe,
> +       .remove = acpi_pad_remove,
> +       .driver = {
> +               .name = "acpi_processor_aggregator",
> +               .acpi_match_table = pad_device_ids,
>         },
>  };
>
> @@ -157,6 +158,6 @@ static int __init xen_acpi_pad_init(void)
>         if (!xen_running_on_version_or_later(4, 2))
>                 return -ENODEV;
>
> -       return acpi_bus_register_driver(&acpi_pad_driver);
> +       return platform_driver_register(&acpi_pad_driver);
>  }
>  subsys_initcall(xen_acpi_pad_init);
> --
> 2.51.0
>
>
>
>
>