mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 0/2] platform/x86: topstar-laptop: Bind to a platform device instead of an ACPI one
@ 2026-03-12 14:31 Rafael J. Wysocki
  2026-03-12 14:32 ` [PATCH v1 1/2] platform/x86: topstar-laptop: Register ACPI notify handler directly Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-03-12 14:31 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86,
	Herton Ronaldo Krzesinski

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 platform x86 Topstar
Laptop ACPI Extras driver.

Patch [1/2] updates the driver to install an ACPI notify handler by itself
instead of using the .notify() callback from struct acpi_driver, which is
requisite for the driver conversion.

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

Thanks!




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

* [PATCH v1 1/2] platform/x86: topstar-laptop: Register ACPI notify handler directly
  2026-03-12 14:31 [PATCH v1 0/2] platform/x86: topstar-laptop: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
@ 2026-03-12 14:32 ` Rafael J. Wysocki
  2026-03-12 14:34 ` [PATCH v1 2/2] platform/x86: topstar-laptop: Convert ACPI driver to a platform one Rafael J. Wysocki
  2026-03-17 18:08 ` [PATCH v1 0/2] platform/x86: topstar-laptop: 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-03-12 14:32 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86,
	Herton Ronaldo Krzesinski

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

To facilitate subsequent conversion of the driver to a platform one,
make it install an ACPI notify handler directly instead of using
a .notify() callback in struct acpi_driver.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/topstar-laptop.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
index a7b4b6c8e549..695ec1d25bcd 100644
--- a/drivers/platform/x86/topstar-laptop.c
+++ b/drivers/platform/x86/topstar-laptop.c
@@ -232,9 +232,9 @@ static int topstar_acpi_fncx_switch(struct acpi_device *device, bool state)
 	return 0;
 }
 
-static void topstar_acpi_notify(struct acpi_device *device, u32 event)
+static void topstar_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
-	struct topstar_laptop *topstar = acpi_driver_data(device);
+	struct topstar_laptop *topstar = data;
 	static bool dup_evnt[2];
 	bool *dup;
 
@@ -313,14 +313,21 @@ static int topstar_acpi_add(struct acpi_device *device)
 	if (err)
 		goto err_platform_exit;
 
+	err = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
+					      topstar_acpi_notify, topstar);
+	if (err)
+		goto err_input_exit;
+
 	if (led_workaround) {
 		err = topstar_led_init(topstar);
 		if (err)
-			goto err_input_exit;
+			goto err_notify_handler_exit;
 	}
 
 	return 0;
 
+err_notify_handler_exit:
+	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, topstar_acpi_notify);
 err_input_exit:
 	topstar_input_exit(topstar);
 err_platform_exit:
@@ -339,6 +346,7 @@ static void topstar_acpi_remove(struct acpi_device *device)
 	if (led_workaround)
 		topstar_led_exit(topstar);
 
+	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, topstar_acpi_notify);
 	topstar_input_exit(topstar);
 	topstar_platform_exit(topstar);
 	topstar_acpi_exit(topstar);
@@ -360,7 +368,6 @@ static struct acpi_driver topstar_acpi_driver = {
 	.ops = {
 		.add = topstar_acpi_add,
 		.remove = topstar_acpi_remove,
-		.notify = topstar_acpi_notify,
 	},
 };
 
-- 
2.51.0





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

* [PATCH v1 2/2] platform/x86: topstar-laptop: Convert ACPI driver to a platform one
  2026-03-12 14:31 [PATCH v1 0/2] platform/x86: topstar-laptop: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
  2026-03-12 14:32 ` [PATCH v1 1/2] platform/x86: topstar-laptop: Register ACPI notify handler directly Rafael J. Wysocki
@ 2026-03-12 14:34 ` Rafael J. Wysocki
  2026-03-17 18:08 ` [PATCH v1 0/2] platform/x86: topstar-laptop: 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-03-12 14:34 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86,
	Herton Ronaldo Krzesinski

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 Topstar Laptop ACPI Extras driver from
an ACPI 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>
---
 drivers/platform/x86/topstar-laptop.c | 30 ++++++++++++++-------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
index 695ec1d25bcd..e09d7f8ce45f 100644
--- a/drivers/platform/x86/topstar-laptop.c
+++ b/drivers/platform/x86/topstar-laptop.c
@@ -285,8 +285,9 @@ static const struct dmi_system_id topstar_dmi_ids[] = {
 	{}
 };
 
-static int topstar_acpi_add(struct acpi_device *device)
+static int topstar_acpi_probe(struct platform_device *pdev)
 {
+	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 	struct topstar_laptop *topstar;
 	int err;
 
@@ -296,9 +297,10 @@ static int topstar_acpi_add(struct acpi_device *device)
 	if (!topstar)
 		return -ENOMEM;
 
+	platform_set_drvdata(pdev, topstar);
+
 	strscpy(acpi_device_name(device), "Topstar TPSACPI");
 	strscpy(acpi_device_class(device), TOPSTAR_LAPTOP_CLASS);
-	device->driver_data = topstar;
 	topstar->device = device;
 
 	err = topstar_acpi_init(topstar);
@@ -339,14 +341,15 @@ static int topstar_acpi_add(struct acpi_device *device)
 	return err;
 }
 
-static void topstar_acpi_remove(struct acpi_device *device)
+static void topstar_acpi_remove(struct platform_device *pdev)
 {
-	struct topstar_laptop *topstar = acpi_driver_data(device);
+	struct topstar_laptop *topstar = platform_get_drvdata(pdev);
 
 	if (led_workaround)
 		topstar_led_exit(topstar);
 
-	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, topstar_acpi_notify);
+	acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
+				       ACPI_DEVICE_NOTIFY, topstar_acpi_notify);
 	topstar_input_exit(topstar);
 	topstar_platform_exit(topstar);
 	topstar_acpi_exit(topstar);
@@ -361,13 +364,12 @@ static const struct acpi_device_id topstar_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, topstar_device_ids);
 
-static struct acpi_driver topstar_acpi_driver = {
-	.name = "Topstar laptop ACPI driver",
-	.class = TOPSTAR_LAPTOP_CLASS,
-	.ids = topstar_device_ids,
-	.ops = {
-		.add = topstar_acpi_add,
-		.remove = topstar_acpi_remove,
+static struct platform_driver topstar_acpi_driver = {
+	.probe = topstar_acpi_probe,
+	.remove = topstar_acpi_remove,
+	.driver = {
+		.name = "Topstar laptop ACPI driver",
+		.acpi_match_table = topstar_device_ids,
 	},
 };
 
@@ -379,7 +381,7 @@ static int __init topstar_laptop_init(void)
 	if (ret < 0)
 		return ret;
 
-	ret = acpi_bus_register_driver(&topstar_acpi_driver);
+	ret = platform_driver_register(&topstar_acpi_driver);
 	if (ret < 0)
 		goto err_driver_unreg;
 
@@ -393,7 +395,7 @@ static int __init topstar_laptop_init(void)
 
 static void __exit topstar_laptop_exit(void)
 {
-	acpi_bus_unregister_driver(&topstar_acpi_driver);
+	platform_driver_unregister(&topstar_acpi_driver);
 	platform_driver_unregister(&topstar_platform_driver);
 }
 
-- 
2.51.0





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

* Re: [PATCH v1 0/2] platform/x86: topstar-laptop: Bind to a platform device instead of an ACPI one
  2026-03-12 14:31 [PATCH v1 0/2] platform/x86: topstar-laptop: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
  2026-03-12 14:32 ` [PATCH v1 1/2] platform/x86: topstar-laptop: Register ACPI notify handler directly Rafael J. Wysocki
  2026-03-12 14:34 ` [PATCH v1 2/2] platform/x86: topstar-laptop: Convert ACPI driver to a platform one Rafael J. Wysocki
@ 2026-03-17 18:08 ` Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2026-03-17 18:08 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86,
	Herton Ronaldo Krzesinski

On Thu, 12 Mar 2026 15:31:16 +0100, 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] platform/x86: topstar-laptop: Register ACPI notify handler directly
      commit: a15d1839c77884ad08b72fe2e18d8df7b32c5c0f
[2/2] platform/x86: topstar-laptop: Convert ACPI driver to a platform one
      commit: 3471415c8186f952b805c441d905d7033c23304a

--
 i.


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

end of thread, other threads:[~2026-03-17 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-12 14:31 [PATCH v1 0/2] platform/x86: topstar-laptop: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
2026-03-12 14:32 ` [PATCH v1 1/2] platform/x86: topstar-laptop: Register ACPI notify handler directly Rafael J. Wysocki
2026-03-12 14:34 ` [PATCH v1 2/2] platform/x86: topstar-laptop: Convert ACPI driver to a platform one Rafael J. Wysocki
2026-03-17 18:08 ` [PATCH v1 0/2] platform/x86: topstar-laptop: 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

all inboxes | Powered by JetHome®