Linux ACPI
 help / color / mirror / Atom feed
* [PATCH v1 0/2] platform/x86: acer-wireless: Bind to a platform device instead of an ACPI one
@ 2026-02-28 15:17 Rafael J. Wysocki
  2026-02-28 15:18 ` [PATCH v1 1/2] platform/x86: acer-wireless: Register ACPI notify handler directly Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-02-28 15:17 UTC (permalink / raw)
  To: Ilpo Järvinen; +Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86

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 acer-wireless
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: acer-wireless: Register ACPI notify handler directly
  2026-02-28 15:17 [PATCH v1 0/2] platform/x86: acer-wireless: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
@ 2026-02-28 15:18 ` Rafael J. Wysocki
  2026-02-28 15:18 ` [PATCH v1 2/2] platform/x86: acer-wireless: Convert ACPI driver to a platform one Rafael J. Wysocki
  2026-03-09 14:58 ` [PATCH v1 0/2] platform/x86: acer-wireless: 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-02-28 15:18 UTC (permalink / raw)
  To: Ilpo Järvinen; +Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86

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/acer-wireless.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/acer-wireless.c b/drivers/platform/x86/acer-wireless.c
index 1b5d935d085a..f44d65d97023 100644
--- a/drivers/platform/x86/acer-wireless.c
+++ b/drivers/platform/x86/acer-wireless.c
@@ -18,8 +18,9 @@ static const struct acpi_device_id acer_wireless_acpi_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, acer_wireless_acpi_ids);
 
-static void acer_wireless_notify(struct acpi_device *adev, u32 event)
+static void acer_wireless_notify(acpi_handle handle, u32 event, void *data)
 {
+	struct acpi_device *adev = data;
 	struct input_dev *idev = acpi_driver_data(adev);
 
 	dev_dbg(&adev->dev, "event=%#x\n", event);
@@ -36,6 +37,7 @@ static void acer_wireless_notify(struct acpi_device *adev, u32 event)
 static int acer_wireless_add(struct acpi_device *adev)
 {
 	struct input_dev *idev;
+	int ret;
 
 	idev = devm_input_allocate_device(&adev->dev);
 	if (!idev)
@@ -50,7 +52,18 @@ static int acer_wireless_add(struct acpi_device *adev)
 	set_bit(EV_KEY, idev->evbit);
 	set_bit(KEY_RFKILL, idev->keybit);
 
-	return input_register_device(idev);
+	ret = input_register_device(idev);
+	if (ret)
+		return ret;
+
+	return acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+					       acer_wireless_notify, adev);
+}
+
+static void acer_wireless_remove(struct acpi_device *adev)
+{
+	acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+				       acer_wireless_notify);
 }
 
 static struct acpi_driver acer_wireless_driver = {
@@ -59,7 +72,7 @@ static struct acpi_driver acer_wireless_driver = {
 	.ids = acer_wireless_acpi_ids,
 	.ops = {
 		.add = acer_wireless_add,
-		.notify = acer_wireless_notify,
+		.remove = acer_wireless_remove,
 	},
 };
 module_acpi_driver(acer_wireless_driver);
-- 
2.51.0





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

* [PATCH v1 2/2] platform/x86: acer-wireless: Convert ACPI driver to a platform one
  2026-02-28 15:17 [PATCH v1 0/2] platform/x86: acer-wireless: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
  2026-02-28 15:18 ` [PATCH v1 1/2] platform/x86: acer-wireless: Register ACPI notify handler directly Rafael J. Wysocki
@ 2026-02-28 15:18 ` Rafael J. Wysocki
  2026-03-09 14:58 ` [PATCH v1 0/2] platform/x86: acer-wireless: 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-02-28 15:18 UTC (permalink / raw)
  To: Ilpo Järvinen; +Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86

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 Acer wireless ACPI driver to a platform
one.

After this change, the subordinate input device will be registered
under the platform device used for driver binding instead of its ACPI
companion.

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/acer-wireless.c | 41 +++++++++++++++-------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/platform/x86/acer-wireless.c b/drivers/platform/x86/acer-wireless.c
index f44d65d97023..f464b13a58af 100644
--- a/drivers/platform/x86/acer-wireless.c
+++ b/drivers/platform/x86/acer-wireless.c
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci_ids.h>
+#include <linux/platform_device.h>
 #include <linux/types.h>
 
 static const struct acpi_device_id acer_wireless_acpi_ids[] = {
@@ -20,12 +21,12 @@ MODULE_DEVICE_TABLE(acpi, acer_wireless_acpi_ids);
 
 static void acer_wireless_notify(acpi_handle handle, u32 event, void *data)
 {
-	struct acpi_device *adev = data;
-	struct input_dev *idev = acpi_driver_data(adev);
+	struct device *dev = data;
+	struct input_dev *idev = dev_get_drvdata(dev);
 
-	dev_dbg(&adev->dev, "event=%#x\n", event);
+	dev_dbg(dev, "event=%#x\n", event);
 	if (event != 0x80) {
-		dev_notice(&adev->dev, "Unknown SMKB event: %#x\n", event);
+		dev_notice(dev, "Unknown SMKB event: %#x\n", event);
 		return;
 	}
 	input_report_key(idev, KEY_RFKILL, 1);
@@ -34,16 +35,16 @@ static void acer_wireless_notify(acpi_handle handle, u32 event, void *data)
 	input_sync(idev);
 }
 
-static int acer_wireless_add(struct acpi_device *adev)
+static int acer_wireless_probe(struct platform_device *pdev)
 {
 	struct input_dev *idev;
 	int ret;
 
-	idev = devm_input_allocate_device(&adev->dev);
+	idev = devm_input_allocate_device(&pdev->dev);
 	if (!idev)
 		return -ENOMEM;
 
-	adev->driver_data = idev;
+	platform_set_drvdata(pdev, idev);
 	idev->name = "Acer Wireless Radio Control";
 	idev->phys = "acer-wireless/input0";
 	idev->id.bustype = BUS_HOST;
@@ -56,26 +57,28 @@ static int acer_wireless_add(struct acpi_device *adev)
 	if (ret)
 		return ret;
 
-	return acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
-					       acer_wireless_notify, adev);
+	return acpi_dev_install_notify_handler(ACPI_COMPANION(&pdev->dev),
+					       ACPI_DEVICE_NOTIFY,
+					       acer_wireless_notify,
+					       &pdev->dev);
 }
 
-static void acer_wireless_remove(struct acpi_device *adev)
+static void acer_wireless_remove(struct platform_device *pdev)
 {
-	acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+	acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
+				       ACPI_DEVICE_NOTIFY,
 				       acer_wireless_notify);
 }
 
-static struct acpi_driver acer_wireless_driver = {
-	.name = "Acer Wireless Radio Control Driver",
-	.class = "hotkey",
-	.ids = acer_wireless_acpi_ids,
-	.ops = {
-		.add = acer_wireless_add,
-		.remove = acer_wireless_remove,
+static struct platform_driver acer_wireless_driver = {
+	.probe = acer_wireless_probe,
+	.remove = acer_wireless_remove,
+	.driver = {
+		.name = "Acer Wireless Radio Control Driver",
+		.acpi_match_table = acer_wireless_acpi_ids,
 	},
 };
-module_acpi_driver(acer_wireless_driver);
+module_platform_driver(acer_wireless_driver);
 
 MODULE_DESCRIPTION("Acer Wireless Radio Control Driver");
 MODULE_AUTHOR("Chris Chiu <chiu@gmail.com>");
-- 
2.51.0





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

* Re: [PATCH v1 0/2] platform/x86: acer-wireless: Bind to a platform device instead of an ACPI one
  2026-02-28 15:17 [PATCH v1 0/2] platform/x86: acer-wireless: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
  2026-02-28 15:18 ` [PATCH v1 1/2] platform/x86: acer-wireless: Register ACPI notify handler directly Rafael J. Wysocki
  2026-02-28 15:18 ` [PATCH v1 2/2] platform/x86: acer-wireless: Convert ACPI driver to a platform one Rafael J. Wysocki
@ 2026-03-09 14:58 ` Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2026-03-09 14:58 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86

On Sat, 28 Feb 2026 16:17:06 +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: acer-wireless: Register ACPI notify handler directly
      commit: 6fdc70794cc15b450e3fd750ca048318764a343e
[2/2] platform/x86: acer-wireless: Convert ACPI driver to a platform one
      commit: b30a462720ad15613ede9e365938d401ed464095

--
 i.


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

end of thread, other threads:[~2026-03-09 14:58 UTC | newest]

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