The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v1 0/2] x86/platform/olpc: xo15: Bind to a platform device instead of an ACPI one
@ 2026-05-08 17:59 Rafael J. Wysocki
  2026-05-08 18:00 ` [PATCH v1 1/2] x86/platform/olpc: xo15: Drop wakeup source on driver removal Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-05-08 17:59 UTC (permalink / raw)
  To: x86 Maintainers
  Cc: Ilpo Järvinen, Hans de Goede, LKML, Linux ACPI,
	platform-driver-x86, Borislav Petkov, Thomas Gleixner,
	Dave Hansen

Hi All,

This series is part of a larger effort to switch over all drivers using
the struct acpi_driver interface to the more common struct platform_driver
interface and eliminate the former.  The background is explained in
Documentation/driver-api/acpi/acpi-drivers.rst and in the changelog of
the patch that introduced the above document:

https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/

The bottom line is that the kernel would be better off without struct
acpi_driver and so it is better to get rid of it.

This series carries out driver conversion of the x86 platform OLPC XO 1.5
driver.

Patch [1/2] fixes a possible wakeup source object leak on driver removal.

Patch [2/2] converts the driver to using struct platform_driver for device
binding.

Off topic: I'm not really sure why the driver is there in arch/x86 because
there really is nothing specific to x86 in it other than relying on some
ACPI hardware to be present, but that's more about the platform than about
the arch.  I guess it my as well be moved to platform/x86/ (there is one
xo15-related driver in there already).

Thanks!




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1 1/2] x86/platform/olpc: xo15: Drop wakeup source on driver removal
  2026-05-08 17:59 [PATCH v1 0/2] x86/platform/olpc: xo15: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
@ 2026-05-08 18:00 ` Rafael J. Wysocki
  2026-05-08 18:01 ` [PATCH v1 2/2] x86/platform/olpc: xo15: Convert ACPI driver to a platform one Rafael J. Wysocki
  2026-05-11 14:15 ` [PATCH v1 0/2] x86/platform/olpc: xo15: Bind to a platform device instead of an ACPI one Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-05-08 18:00 UTC (permalink / raw)
  To: x86 Maintainers
  Cc: Ilpo Järvinen, Hans de Goede, LKML, Linux ACPI,
	platform-driver-x86, Borislav Petkov, Thomas Gleixner,
	Dave Hansen

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

Prevent leaking a wakeup source object after removing the driver by
adding appropriate cleanup code to its remove callback function.

Fixes: a0f30f592d2d ("x86, olpc: Add XO-1.5 SCI driver")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 arch/x86/platform/olpc/olpc-xo15-sci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c b/arch/x86/platform/olpc/olpc-xo15-sci.c
index 82c51b6ec528..276caf756a9c 100644
--- a/arch/x86/platform/olpc/olpc-xo15-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo15-sci.c
@@ -186,6 +186,7 @@ static int xo15_sci_add(struct acpi_device *device)
 
 static void xo15_sci_remove(struct acpi_device *device)
 {
+	device_init_wakeup(&device->dev, false);
 	acpi_disable_gpe(NULL, xo15_sci_gpe);
 	acpi_remove_gpe_handler(NULL, xo15_sci_gpe, xo15_sci_gpe_handler);
 	cancel_work_sync(&sci_work);




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v1 2/2] x86/platform/olpc: xo15: Convert ACPI driver to a platform one
  2026-05-08 17:59 [PATCH v1 0/2] x86/platform/olpc: xo15: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
  2026-05-08 18:00 ` [PATCH v1 1/2] x86/platform/olpc: xo15: Drop wakeup source on driver removal Rafael J. Wysocki
@ 2026-05-08 18:01 ` Rafael J. Wysocki
  2026-05-11 14:15 ` [PATCH v1 0/2] x86/platform/olpc: xo15: Bind to a platform device instead of an ACPI one Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-05-08 18:01 UTC (permalink / raw)
  To: x86 Maintainers
  Cc: Ilpo Järvinen, Hans de Goede, LKML, Linux ACPI,
	platform-driver-x86, Borislav Petkov, Thomas Gleixner,
	Dave Hansen

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 olpc-xo15-sci ACPI driver to a platform
one.

After this change, the wakeup source added by the driver will appear
under the platform device used for driver binding, but the sysfs
attribute added by the driver under the ACPI companion of that device
will stay there in case there are utilities in user space expecting it
to be there.

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>
---
 arch/x86/platform/olpc/olpc-xo15-sci.c | 34 ++++++++++++++------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c b/arch/x86/platform/olpc/olpc-xo15-sci.c
index 276caf756a9c..e486109e88c8 100644
--- a/arch/x86/platform/olpc/olpc-xo15-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo15-sci.c
@@ -9,6 +9,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/workqueue.h>
+#include <linux/platform_device.h>
 #include <linux/power_supply.h>
 #include <linux/olpc-ec.h>
 
@@ -136,14 +137,16 @@ static u32 xo15_sci_gpe_handler(acpi_handle gpe_device, u32 gpe, void *context)
 	return ACPI_INTERRUPT_HANDLED | ACPI_REENABLE_GPE;
 }
 
-static int xo15_sci_add(struct acpi_device *device)
+static int xo15_sci_probe(struct platform_device *pdev)
 {
+	struct acpi_device *device;
 	unsigned long long tmp;
 	acpi_status status;
 	int r;
 
+	device = ACPI_COMPANION(&pdev->dev);
 	if (!device)
-		return -EINVAL;
+		return -ENODEV;
 
 	strscpy(acpi_device_name(device), XO15_SCI_DEVICE_NAME);
 	strscpy(acpi_device_class(device), XO15_SCI_CLASS);
@@ -160,7 +163,7 @@ static int xo15_sci_add(struct acpi_device *device)
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
 
-	dev_info(&device->dev, "Initialized, GPE = 0x%lx\n", xo15_sci_gpe);
+	dev_info(&pdev->dev, "Initialized, GPE = 0x%lx\n", xo15_sci_gpe);
 
 	r = sysfs_create_file(&device->dev.kobj, &lid_wake_on_close_attr.attr);
 	if (r)
@@ -174,7 +177,7 @@ static int xo15_sci_add(struct acpi_device *device)
 
 	/* Enable wake-on-EC */
 	if (device->wakeup.flags.valid)
-		device_init_wakeup(&device->dev, true);
+		device_init_wakeup(&pdev->dev, true);
 
 	return 0;
 
@@ -184,9 +187,11 @@ static int xo15_sci_add(struct acpi_device *device)
 	return r;
 }
 
-static void xo15_sci_remove(struct acpi_device *device)
+static void xo15_sci_remove(struct platform_device *pdev)
 {
-	device_init_wakeup(&device->dev, false);
+	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+
+	device_init_wakeup(&pdev->dev, false);
 	acpi_disable_gpe(NULL, xo15_sci_gpe);
 	acpi_remove_gpe_handler(NULL, xo15_sci_gpe, xo15_sci_gpe_handler);
 	cancel_work_sync(&sci_work);
@@ -214,19 +219,18 @@ static const struct acpi_device_id xo15_sci_device_ids[] = {
 	{"", 0},
 };
 
-static struct acpi_driver xo15_sci_drv = {
-	.name = DRV_NAME,
-	.class = XO15_SCI_CLASS,
-	.ids = xo15_sci_device_ids,
-	.ops = {
-		.add = xo15_sci_add,
-		.remove = xo15_sci_remove,
+static struct platform_driver xo15_sci_drv = {
+	.probe = xo15_sci_probe,
+	.remove = xo15_sci_remove,
+	.driver = {
+		.name = DRV_NAME,
+		.acpi_match_table = xo15_sci_device_ids,
+		.pm = &xo15_sci_pm,
 	},
-	.drv.pm = &xo15_sci_pm,
 };
 
 static int __init xo15_sci_init(void)
 {
-	return acpi_bus_register_driver(&xo15_sci_drv);
+	return platform_driver_register(&xo15_sci_drv);
 }
 device_initcall(xo15_sci_init);
-- 
2.51.0





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 0/2] x86/platform/olpc: xo15: Bind to a platform device instead of an ACPI one
  2026-05-08 17:59 [PATCH v1 0/2] x86/platform/olpc: xo15: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
  2026-05-08 18:00 ` [PATCH v1 1/2] x86/platform/olpc: xo15: Drop wakeup source on driver removal Rafael J. Wysocki
  2026-05-08 18:01 ` [PATCH v1 2/2] x86/platform/olpc: xo15: Convert ACPI driver to a platform one Rafael J. Wysocki
@ 2026-05-11 14:15 ` Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2026-05-11 14:15 UTC (permalink / raw)
  To: x86 Maintainers, Rafael J. Wysocki
  Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86,
	Borislav Petkov, Dave Hansen, Thomas Gleixner

On Fri, 08 May 2026 19:59:27 +0200, Rafael J. Wysocki wrote:

> This series is part of a larger effort to switch over all drivers using
> the struct acpi_driver interface to the more common struct platform_driver
> interface and eliminate the former.  The background is explained in
> Documentation/driver-api/acpi/acpi-drivers.rst and in the changelog of
> the patch that introduced the above document:
> 
> https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/2] x86/platform/olpc: xo15: Drop wakeup source on driver removal
      commit: cc966553e6ff0849978b5754531b768b0ff54985
[2/2] x86/platform/olpc: xo15: Convert ACPI driver to a platform one
      commit: 75c7d3d76b78b568969316224c8ae25c0224cc9a

--
 i.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-11 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 17:59 [PATCH v1 0/2] x86/platform/olpc: xo15: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
2026-05-08 18:00 ` [PATCH v1 1/2] x86/platform/olpc: xo15: Drop wakeup source on driver removal Rafael J. Wysocki
2026-05-08 18:01 ` [PATCH v1 2/2] x86/platform/olpc: xo15: Convert ACPI driver to a platform one Rafael J. Wysocki
2026-05-11 14:15 ` [PATCH v1 0/2] x86/platform/olpc: xo15: Bind to a platform device instead of an ACPI one Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox