Skip to contentSkip to conversation

platform/x86: asus: Bind drivers to platform devices instead of ACPI ones

PATCH In review Rafael J. Wysocki 3 participants 14 messages Feb 28 – Apr 7

Subsystems (4)
lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

cover platform/x86: asus: Bind drivers to platform devices instead of ACPI ones

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/[email protected]/

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 conversions of the platform x86 drivers for Asus platforms.

Patch [1/4] updates the asus-laptop 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.

Patche [2/4] converts the asus-laptop driver to using struct platform_driver for device binding.

Patch [3/4] updates the asus-wireless 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.

Patche [4/4] converts the asus-wireless driver to using struct platform_driver for device binding.

Thanks!

author maintainer
#1 lore raw

PATCH 1/4 platform/x86: asus-laptop: Register ACPI notify handler directly

From: "Rafael J. Wysocki" <[email protected]>

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.

---
 drivers/platform/x86/asus-laptop.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/platform/x86/asus-laptop.c +8 -3
index d96f6af26ff7..c927665dfa96 100644
@@ -1517,9 +1517,9 @@ static void asus_input_exit(struct asus_laptop *asus)
 /*
  * ACPI driver
  */
-static void asus_acpi_notify(struct acpi_device *device, u32 event)
+static void asus_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
-	struct asus_laptop *asus = acpi_driver_data(device);
+	struct asus_laptop *asus = data;
 	u16 count;
 
 	/* TODO Find a better way to handle events count. */
@@ -1881,6 +1881,11 @@ static int asus_acpi_add(struct acpi_device *device)
 	if (result && result != -ENODEV)
 		goto fail_pega_rfkill;
 
+	result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
+						 asus_acpi_notify, asus);
+	if (result)
+		goto fail_pega_rfkill;
+
 	asus_device_present = true;
 	return 0;
 
@@ -1906,6 +1911,7 @@ static void asus_acpi_remove(struct acpi_device *device)
 {
 	struct asus_laptop *asus = acpi_driver_data(device);
 
+	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
 	asus_backlight_exit(asus);
 	asus_rfkill_exit(asus);
 	asus_led_exit(asus);
@@ -1932,7 +1938,6 @@ static struct acpi_driver asus_acpi_driver = {
 	.ops = {
 		.add = asus_acpi_add,
 		.remove = asus_acpi_remove,
-		.notify = asus_acpi_notify,
 		},
 };
 
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH v1 1/4] platform/x86: asus-laptop: Register ACPI notify handler directly

Quoted 7 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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.

Quoted 49 lines
---
 drivers/platform/x86/asus-laptop.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/platform/x86/asus-laptop.c +8 -3
index d96f6af26ff7..c927665dfa96 100644
@@ -1517,9 +1517,9 @@ static void asus_input_exit(struct asus_laptop *asus)
 /*
  * ACPI driver
  */
-static void asus_acpi_notify(struct acpi_device *device, u32 event)
+static void asus_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
-	struct asus_laptop *asus = acpi_driver_data(device);
+	struct asus_laptop *asus = data;
 	u16 count;
 
 	/* TODO Find a better way to handle events count. */
@@ -1881,6 +1881,11 @@ static int asus_acpi_add(struct acpi_device *device)
 	if (result && result != -ENODEV)
 		goto fail_pega_rfkill;
 
+	result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
+						 asus_acpi_notify, asus);
+	if (result)
+		goto fail_pega_rfkill;
+
 	asus_device_present = true;
 	return 0;
 
@@ -1906,6 +1911,7 @@ static void asus_acpi_remove(struct acpi_device *device)
 {
 	struct asus_laptop *asus = acpi_driver_data(device);
 
+	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
 	asus_backlight_exit(asus);
 	asus_rfkill_exit(asus);
 	asus_led_exit(asus);
@@ -1932,7 +1938,6 @@ static struct acpi_driver asus_acpi_driver = {
 	.ops = {
 		.add = asus_acpi_add,
 		.remove = asus_acpi_remove,
-		.notify = asus_acpi_notify,
 		},
 };
 
author maintainer
#3 lore raw

PATCH 2/4 platform/x86: asus-laptop: Convert ACPI driver to a platform one

In reply to Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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 Asus laptop 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.

---
 drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/platform/x86/asus-laptop.c +18 -17
index c927665dfa96..dbbb6292cd11 100644
@@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
 
 static bool asus_device_present;
 
-static int asus_acpi_add(struct acpi_device *device)
+static int asus_acpi_probe(struct platform_device *pdev)
 {
+	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 	struct asus_laptop *asus;
 	int result;
 
@@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
 	asus->handle = device->handle;
 	strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
-	device->driver_data = asus;
 	asus->device = device;
 
 	asus_dmi_check();
@@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
 	if (result)
 		goto fail_platform;
 
+	platform_set_drvdata(pdev, asus);
+
 	/*
 	 * Need platform type detection first, then the platform
 	 * device.  It is used as a parent for the sub-devices below.
@@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
 	return result;
 }
 
-static void asus_acpi_remove(struct acpi_device *device)
+static void asus_acpi_remove(struct platform_device *pdev)
 {
-	struct asus_laptop *asus = acpi_driver_data(device);
+	struct asus_laptop *asus = platform_get_drvdata(pdev);
 
-	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
+	acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
+				       asus_acpi_notify);
 	asus_backlight_exit(asus);
 	asus_rfkill_exit(asus);
 	asus_led_exit(asus);
@@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, asus_device_ids);
 
-static struct acpi_driver asus_acpi_driver = {
-	.name = ASUS_LAPTOP_NAME,
-	.class = ASUS_LAPTOP_CLASS,
-	.ids = asus_device_ids,
-	.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
-	.ops = {
-		.add = asus_acpi_add,
-		.remove = asus_acpi_remove,
-		},
+static struct platform_driver asus_acpi_driver = {
+	.probe = asus_acpi_probe,
+	.remove = asus_acpi_remove,
+	.driver = {
+		.name = ASUS_LAPTOP_NAME,
+		.acpi_match_table = asus_device_ids,
+	},
 };
 
 static int __init asus_laptop_init(void)
@@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
 	if (result < 0)
 		return result;
 
-	result = acpi_bus_register_driver(&asus_acpi_driver);
+	result = platform_driver_register(&asus_acpi_driver);
 	if (result < 0)
 		goto fail_acpi_driver;
 	if (!asus_device_present) {
@@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
 	return 0;
 
 fail_no_device:
-	acpi_bus_unregister_driver(&asus_acpi_driver);
+	platform_driver_unregister(&asus_acpi_driver);
 fail_acpi_driver:
 	platform_driver_unregister(&platform_driver);
 	return result;
@@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
 
 static void __exit asus_laptop_exit(void)
 {
-	acpi_bus_unregister_driver(&asus_acpi_driver);
+	platform_driver_unregister(&asus_acpi_driver);
 	platform_driver_unregister(&platform_driver);
 }
 
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH v1 2/4] platform/x86: asus-laptop: Convert ACPI driver to a platform one

Quoted 9 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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

Quoted 6 lines

Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the Asus laptop 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.

Alright I will take a look if asus-linux software is affected and act accordingly. How much time do I have?

Thanks.

Quoted 2 lines
Quoted 102 lines
---
 drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/platform/x86/asus-laptop.c +18 -17
index c927665dfa96..dbbb6292cd11 100644
@@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
 
 static bool asus_device_present;
 
-static int asus_acpi_add(struct acpi_device *device)
+static int asus_acpi_probe(struct platform_device *pdev)
 {
+	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 	struct asus_laptop *asus;
 	int result;
 
@@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
 	asus->handle = device->handle;
 	strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
-	device->driver_data = asus;
 	asus->device = device;
 
 	asus_dmi_check();
@@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
 	if (result)
 		goto fail_platform;
 
+	platform_set_drvdata(pdev, asus);
+
 	/*
 	 * Need platform type detection first, then the platform
 	 * device.  It is used as a parent for the sub-devices below.
@@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
 	return result;
 }
 
-static void asus_acpi_remove(struct acpi_device *device)
+static void asus_acpi_remove(struct platform_device *pdev)
 {
-	struct asus_laptop *asus = acpi_driver_data(device);
+	struct asus_laptop *asus = platform_get_drvdata(pdev);
 
-	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
+	acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
+				       asus_acpi_notify);
 	asus_backlight_exit(asus);
 	asus_rfkill_exit(asus);
 	asus_led_exit(asus);
@@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, asus_device_ids);
 
-static struct acpi_driver asus_acpi_driver = {
-	.name = ASUS_LAPTOP_NAME,
-	.class = ASUS_LAPTOP_CLASS,
-	.ids = asus_device_ids,
-	.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
-	.ops = {
-		.add = asus_acpi_add,
-		.remove = asus_acpi_remove,
-		},
+static struct platform_driver asus_acpi_driver = {
+	.probe = asus_acpi_probe,
+	.remove = asus_acpi_remove,
+	.driver = {
+		.name = ASUS_LAPTOP_NAME,
+		.acpi_match_table = asus_device_ids,
+	},
 };
 
 static int __init asus_laptop_init(void)
@@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
 	if (result < 0)
 		return result;
 
-	result = acpi_bus_register_driver(&asus_acpi_driver);
+	result = platform_driver_register(&asus_acpi_driver);
 	if (result < 0)
 		goto fail_acpi_driver;
 	if (!asus_device_present) {
@@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
 	return 0;
 
 fail_no_device:
-	acpi_bus_unregister_driver(&asus_acpi_driver);
+	platform_driver_unregister(&asus_acpi_driver);
 fail_acpi_driver:
 	platform_driver_unregister(&platform_driver);
 	return result;
@@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
 
 static void __exit asus_laptop_exit(void)
 {
-	acpi_bus_unregister_driver(&asus_acpi_driver);
+	platform_driver_unregister(&asus_acpi_driver);
 	platform_driver_unregister(&platform_driver);
 }
 
author maintainer
#5 lore raw

Re: [PATCH v1 2/4] platform/x86: asus-laptop: Convert ACPI driver to a platform one

Quoted 16 lines · Denis Benato
Quoted 13 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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 Asus laptop ACPI driver to a platform one.

Quoted 5 lines
Quoted 2 lines

While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space.

Alright I will take a look if asus-linux software is affected and act accordingly. How much time do I have?

It really depends on Ilpo, but there's no rush as far as I'm concerned.

Quoted 4 lines

Thanks.

Quoted 2 lines

Thanks for all of the reviews!

Quoted 102 lines
Quoted 102 lines
---
 drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/platform/x86/asus-laptop.c +18 -17
index c927665dfa96..dbbb6292cd11 100644
@@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
 
 static bool asus_device_present;
 
-static int asus_acpi_add(struct acpi_device *device)
+static int asus_acpi_probe(struct platform_device *pdev)
 {
+     struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
      struct asus_laptop *asus;
      int result;
 
@@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
      asus->handle = device->handle;
      strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
      strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
-     device->driver_data = asus;
      asus->device = device;
 
      asus_dmi_check();
@@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
      if (result)
              goto fail_platform;
 
+     platform_set_drvdata(pdev, asus);
+
      /*
       * Need platform type detection first, then the platform
       * device.  It is used as a parent for the sub-devices below.
@@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
      return result;
 }
 
-static void asus_acpi_remove(struct acpi_device *device)
+static void asus_acpi_remove(struct platform_device *pdev)
 {
-     struct asus_laptop *asus = acpi_driver_data(device);
+     struct asus_laptop *asus = platform_get_drvdata(pdev);
 
-     acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
+     acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
+                                    asus_acpi_notify);
      asus_backlight_exit(asus);
      asus_rfkill_exit(asus);
      asus_led_exit(asus);
@@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, asus_device_ids);
 
-static struct acpi_driver asus_acpi_driver = {
-     .name = ASUS_LAPTOP_NAME,
-     .class = ASUS_LAPTOP_CLASS,
-     .ids = asus_device_ids,
-     .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
-     .ops = {
-             .add = asus_acpi_add,
-             .remove = asus_acpi_remove,
-             },
+static struct platform_driver asus_acpi_driver = {
+     .probe = asus_acpi_probe,
+     .remove = asus_acpi_remove,
+     .driver = {
+             .name = ASUS_LAPTOP_NAME,
+             .acpi_match_table = asus_device_ids,
+     },
 };
 
 static int __init asus_laptop_init(void)
@@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
      if (result < 0)
              return result;
 
-     result = acpi_bus_register_driver(&asus_acpi_driver);
+     result = platform_driver_register(&asus_acpi_driver);
      if (result < 0)
              goto fail_acpi_driver;
      if (!asus_device_present) {
@@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
      return 0;
 
 fail_no_device:
-     acpi_bus_unregister_driver(&asus_acpi_driver);
+     platform_driver_unregister(&asus_acpi_driver);
 fail_acpi_driver:
      platform_driver_unregister(&platform_driver);
      return result;
@@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
 
 static void __exit asus_laptop_exit(void)
 {
-     acpi_bus_unregister_driver(&asus_acpi_driver);
+     platform_driver_unregister(&asus_acpi_driver);
      platform_driver_unregister(&platform_driver);
 }
 
maintainer
#6 lore raw

Re: [PATCH v1 2/4] platform/x86: asus-laptop: Convert ACPI driver to a platform one

In reply to Denis Benato
Quoted 14 lines · Denis Benato
Quoted 13 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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 Asus laptop ACPI driver to a platform one.

Quoted 5 lines
Quoted 2 lines

While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space.

Alright I will take a look if asus-linux software is affected and act accordingly. How much time do I have?

Please take your time, we don't need to rush things, especially refactoring when there are open questions to answer.

Quoted 4 lines

Thanks.

Quoted 2 lines
Signature · 1 line
 i.
maintainer
#7 lore raw

Re: [PATCH v1 2/4] platform/x86: asus-laptop: Convert ACPI driver to a platform one

In reply to Denis Benato
Quoted 14 lines · Denis Benato
Quoted 13 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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 Asus laptop ACPI driver to a platform one.

Quoted 7 lines
Quoted 2 lines

While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space.

Alright I will take a look if asus-linux software is affected and act accordingly. How much time do I have?

Thanks.

Hi Denis,

Has there been some progress with this check?

--
i.

Quoted 106 lines
Quoted 2 lines
Quoted 102 lines
---
 drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/platform/x86/asus-laptop.c +18 -17
index c927665dfa96..dbbb6292cd11 100644
@@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
 
 static bool asus_device_present;
 
-static int asus_acpi_add(struct acpi_device *device)
+static int asus_acpi_probe(struct platform_device *pdev)
 {
+	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 	struct asus_laptop *asus;
 	int result;
 
@@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
 	asus->handle = device->handle;
 	strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
-	device->driver_data = asus;
 	asus->device = device;
 
 	asus_dmi_check();
@@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
 	if (result)
 		goto fail_platform;
 
+	platform_set_drvdata(pdev, asus);
+
 	/*
 	 * Need platform type detection first, then the platform
 	 * device.  It is used as a parent for the sub-devices below.
@@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
 	return result;
 }
 
-static void asus_acpi_remove(struct acpi_device *device)
+static void asus_acpi_remove(struct platform_device *pdev)
 {
-	struct asus_laptop *asus = acpi_driver_data(device);
+	struct asus_laptop *asus = platform_get_drvdata(pdev);
 
-	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
+	acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
+				       asus_acpi_notify);
 	asus_backlight_exit(asus);
 	asus_rfkill_exit(asus);
 	asus_led_exit(asus);
@@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, asus_device_ids);
 
-static struct acpi_driver asus_acpi_driver = {
-	.name = ASUS_LAPTOP_NAME,
-	.class = ASUS_LAPTOP_CLASS,
-	.ids = asus_device_ids,
-	.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
-	.ops = {
-		.add = asus_acpi_add,
-		.remove = asus_acpi_remove,
-		},
+static struct platform_driver asus_acpi_driver = {
+	.probe = asus_acpi_probe,
+	.remove = asus_acpi_remove,
+	.driver = {
+		.name = ASUS_LAPTOP_NAME,
+		.acpi_match_table = asus_device_ids,
+	},
 };
 
 static int __init asus_laptop_init(void)
@@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
 	if (result < 0)
 		return result;
 
-	result = acpi_bus_register_driver(&asus_acpi_driver);
+	result = platform_driver_register(&asus_acpi_driver);
 	if (result < 0)
 		goto fail_acpi_driver;
 	if (!asus_device_present) {
@@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
 	return 0;
 
 fail_no_device:
-	acpi_bus_unregister_driver(&asus_acpi_driver);
+	platform_driver_unregister(&asus_acpi_driver);
 fail_acpi_driver:
 	platform_driver_unregister(&platform_driver);
 	return result;
@@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
 
 static void __exit asus_laptop_exit(void)
 {
-	acpi_bus_unregister_driver(&asus_acpi_driver);
+	platform_driver_unregister(&asus_acpi_driver);
 	platform_driver_unregister(&platform_driver);
 }
 
maintainer
#8 lore raw

Re: [PATCH v1 2/4] platform/x86: asus-laptop: Convert ACPI driver to a platform one

Quoted 17 lines · Ilpo Järvinen
Quoted 16 lines · Denis Benato
Quoted 15 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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 Asus laptop 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.

Quoted 7 lines
Quoted 4 lines

Alright I will take a look if asus-linux software is affected and act accordingly. How much time do I have?

Thanks.

Hi Denis,

Has there been some progress with this check?

Hi!

I quickly looked at it and I think there shouldn't be any problem.

Worst case scenario I update the criteria udev uses to find certain things but it shouldn't be necessary (or at least I can't find a problematic spot).

Thanks,
Denis

Quoted 108 lines

--
i.

Quoted 105 lines
Quoted 2 lines
Quoted 102 lines
---
 drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/platform/x86/asus-laptop.c +18 -17
index c927665dfa96..dbbb6292cd11 100644
@@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
 
 static bool asus_device_present;
 
-static int asus_acpi_add(struct acpi_device *device)
+static int asus_acpi_probe(struct platform_device *pdev)
 {
+	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 	struct asus_laptop *asus;
 	int result;
 
@@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
 	asus->handle = device->handle;
 	strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
-	device->driver_data = asus;
 	asus->device = device;
 
 	asus_dmi_check();
@@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
 	if (result)
 		goto fail_platform;
 
+	platform_set_drvdata(pdev, asus);
+
 	/*
 	 * Need platform type detection first, then the platform
 	 * device.  It is used as a parent for the sub-devices below.
@@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
 	return result;
 }
 
-static void asus_acpi_remove(struct acpi_device *device)
+static void asus_acpi_remove(struct platform_device *pdev)
 {
-	struct asus_laptop *asus = acpi_driver_data(device);
+	struct asus_laptop *asus = platform_get_drvdata(pdev);
 
-	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
+	acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
+				       asus_acpi_notify);
 	asus_backlight_exit(asus);
 	asus_rfkill_exit(asus);
 	asus_led_exit(asus);
@@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, asus_device_ids);
 
-static struct acpi_driver asus_acpi_driver = {
-	.name = ASUS_LAPTOP_NAME,
-	.class = ASUS_LAPTOP_CLASS,
-	.ids = asus_device_ids,
-	.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
-	.ops = {
-		.add = asus_acpi_add,
-		.remove = asus_acpi_remove,
-		},
+static struct platform_driver asus_acpi_driver = {
+	.probe = asus_acpi_probe,
+	.remove = asus_acpi_remove,
+	.driver = {
+		.name = ASUS_LAPTOP_NAME,
+		.acpi_match_table = asus_device_ids,
+	},
 };
 
 static int __init asus_laptop_init(void)
@@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
 	if (result < 0)
 		return result;
 
-	result = acpi_bus_register_driver(&asus_acpi_driver);
+	result = platform_driver_register(&asus_acpi_driver);
 	if (result < 0)
 		goto fail_acpi_driver;
 	if (!asus_device_present) {
@@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
 	return 0;
 
 fail_no_device:
-	acpi_bus_unregister_driver(&asus_acpi_driver);
+	platform_driver_unregister(&asus_acpi_driver);
 fail_acpi_driver:
 	platform_driver_unregister(&platform_driver);
 	return result;
@@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
 
 static void __exit asus_laptop_exit(void)
 {
-	acpi_bus_unregister_driver(&asus_acpi_driver);
+	platform_driver_unregister(&asus_acpi_driver);
 	platform_driver_unregister(&platform_driver);
 }
 
author maintainer
#9 lore raw

PATCH 3/4 platform/x86: asus-wireless: Register ACPI notify handler directly

In reply to Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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.

---
 drivers/platform/x86/asus-wireless.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/platform/x86/asus-wireless.c +16 -4
index 41227bf95878..45d41875c515 100644
@@ -108,9 +108,10 @@ static void led_state_set(struct led_classdev *led, enum led_brightness value)
 	queue_work(data->wq, &data->led_work);
 }
 
-static void asus_wireless_notify(struct acpi_device *adev, u32 event)
+static void asus_wireless_notify(acpi_handle handle, u32 event, void *context)
 {
-	struct asus_wireless_data *data = acpi_driver_data(adev);
+	struct asus_wireless_data *data = context;
+	struct acpi_device *adev = data->adev;
 
 	dev_dbg(&adev->dev, "event=%#x\n", event);
 	if (event != 0x88) {
@@ -166,8 +167,18 @@ static int asus_wireless_add(struct acpi_device *adev)
 	data->led.default_trigger = "rfkill-none";
 	err = devm_led_classdev_register(&adev->dev, &data->led);
 	if (err)
-		destroy_workqueue(data->wq);
+		goto err;
+
+	err = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+					      asus_wireless_notify, data);
+	if (err) {
+		devm_led_classdev_unregister(&adev->dev, &data->led);
+		goto err;
+	}
+	return 0;
 
+err:
+	destroy_workqueue(data->wq);
 	return err;
 }
 
@@ -175,6 +186,8 @@ static void asus_wireless_remove(struct acpi_device *adev)
 {
 	struct asus_wireless_data *data = acpi_driver_data(adev);
 
+	acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+				       asus_wireless_notify);
 	if (data->wq) {
 		devm_led_classdev_unregister(&adev->dev, &data->led);
 		destroy_workqueue(data->wq);
@@ -188,7 +201,6 @@ static struct acpi_driver asus_wireless_driver = {
 	.ops = {
 		.add = asus_wireless_add,
 		.remove = asus_wireless_remove,
-		.notify = asus_wireless_notify,
 	},
 };
 module_acpi_driver(asus_wireless_driver);
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 3/4
#10 lore raw

Re: [PATCH v1 3/4] platform/x86: asus-wireless: Register ACPI notify handler directly

Quoted 7 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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.

Quoted 59 lines
---
 drivers/platform/x86/asus-wireless.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/platform/x86/asus-wireless.c +16 -4
index 41227bf95878..45d41875c515 100644
@@ -108,9 +108,10 @@ static void led_state_set(struct led_classdev *led, enum led_brightness value)
 	queue_work(data->wq, &data->led_work);
 }
 
-static void asus_wireless_notify(struct acpi_device *adev, u32 event)
+static void asus_wireless_notify(acpi_handle handle, u32 event, void *context)
 {
-	struct asus_wireless_data *data = acpi_driver_data(adev);
+	struct asus_wireless_data *data = context;
+	struct acpi_device *adev = data->adev;
 
 	dev_dbg(&adev->dev, "event=%#x\n", event);
 	if (event != 0x88) {
@@ -166,8 +167,18 @@ static int asus_wireless_add(struct acpi_device *adev)
 	data->led.default_trigger = "rfkill-none";
 	err = devm_led_classdev_register(&adev->dev, &data->led);
 	if (err)
-		destroy_workqueue(data->wq);
+		goto err;
+
+	err = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+					      asus_wireless_notify, data);
+	if (err) {
+		devm_led_classdev_unregister(&adev->dev, &data->led);
+		goto err;
+	}
+	return 0;
 
+err:
+	destroy_workqueue(data->wq);
 	return err;
 }
 
@@ -175,6 +186,8 @@ static void asus_wireless_remove(struct acpi_device *adev)
 {
 	struct asus_wireless_data *data = acpi_driver_data(adev);
 
+	acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+				       asus_wireless_notify);
 	if (data->wq) {
 		devm_led_classdev_unregister(&adev->dev, &data->led);
 		destroy_workqueue(data->wq);
@@ -188,7 +201,6 @@ static struct acpi_driver asus_wireless_driver = {
 	.ops = {
 		.add = asus_wireless_add,
 		.remove = asus_wireless_remove,
-		.notify = asus_wireless_notify,
 	},
 };
 module_acpi_driver(asus_wireless_driver);
author maintainer
#11 lore raw

PATCH 4/4 platform/x86: asus-wireless: Convert ACPI driver to a platform one

In reply to Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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

After this change, the subordinate input and LED devices 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.

---
 drivers/platform/x86/asus-wireless.c | 39 +++++++++++++++-------------
 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/platform/x86/asus-wireless.c +21 -18
index 45d41875c515..2b494bf3cba8 100644
@@ -12,6 +12,7 @@
 #include <linux/acpi.h>
 #include <linux/input.h>
 #include <linux/pci_ids.h>
+#include <linux/platform_device.h>
 #include <linux/leds.h>
 
 struct hswc_params {
@@ -124,19 +125,22 @@ static void asus_wireless_notify(acpi_handle handle, u32 event, void *context)
 	input_sync(data->idev);
 }
 
-static int asus_wireless_add(struct acpi_device *adev)
+static int asus_wireless_probe(struct platform_device *pdev)
 {
+	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
 	struct asus_wireless_data *data;
 	const struct acpi_device_id *id;
 	int err;
 
-	data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
-	adev->driver_data = data;
+
+	platform_set_drvdata(pdev, data);
+
 	data->adev = adev;
 
-	data->idev = devm_input_allocate_device(&adev->dev);
+	data->idev = devm_input_allocate_device(&pdev->dev);
 	if (!data->idev)
 		return -ENOMEM;
 	data->idev->name = "Asus Wireless Radio Control";
@@ -165,14 +169,14 @@ static int asus_wireless_add(struct acpi_device *adev)
 	data->led.flags = LED_CORE_SUSPENDRESUME;
 	data->led.max_brightness = 1;
 	data->led.default_trigger = "rfkill-none";
-	err = devm_led_classdev_register(&adev->dev, &data->led);
+	err = devm_led_classdev_register(&pdev->dev, &data->led);
 	if (err)
 		goto err;
 
 	err = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
 					      asus_wireless_notify, data);
 	if (err) {
-		devm_led_classdev_unregister(&adev->dev, &data->led);
+		devm_led_classdev_unregister(&pdev->dev, &data->led);
 		goto err;
 	}
 	return 0;
@@ -182,28 +186,27 @@ static int asus_wireless_add(struct acpi_device *adev)
 	return err;
 }
 
-static void asus_wireless_remove(struct acpi_device *adev)
+static void asus_wireless_remove(struct platform_device *pdev)
 {
-	struct asus_wireless_data *data = acpi_driver_data(adev);
+	struct asus_wireless_data *data = platform_get_drvdata(pdev);
 
-	acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+	acpi_dev_remove_notify_handler(data->adev, ACPI_DEVICE_NOTIFY,
 				       asus_wireless_notify);
 	if (data->wq) {
-		devm_led_classdev_unregister(&adev->dev, &data->led);
+		devm_led_classdev_unregister(&pdev->dev, &data->led);
 		destroy_workqueue(data->wq);
 	}
 }
 
-static struct acpi_driver asus_wireless_driver = {
-	.name = "Asus Wireless Radio Control Driver",
-	.class = "hotkey",
-	.ids = device_ids,
-	.ops = {
-		.add = asus_wireless_add,
-		.remove = asus_wireless_remove,
+static struct platform_driver asus_wireless_driver = {
+	.probe = asus_wireless_probe,
+	.remove = asus_wireless_remove,
+	.driver = {
+		.name = "Asus Wireless Radio Control Driver",
+		.acpi_match_table = device_ids,
 	},
 };
-module_acpi_driver(asus_wireless_driver);
+module_platform_driver(asus_wireless_driver);
 
 MODULE_DESCRIPTION("Asus Wireless Radio Control Driver");
 MODULE_AUTHOR("João Paulo Rechi Vita <[email protected]>");
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 4/4
#12 lore raw

Re: [PATCH v1 4/4] platform/x86: asus-wireless: Convert ACPI driver to a platform one

Quoted 17 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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

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

Quoted 5 lines

While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space.

Quoted 100 lines
---
 drivers/platform/x86/asus-wireless.c | 39 +++++++++++++++-------------
 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/platform/x86/asus-wireless.c +21 -18
index 45d41875c515..2b494bf3cba8 100644
@@ -12,6 +12,7 @@
 #include <linux/acpi.h>
 #include <linux/input.h>
 #include <linux/pci_ids.h>
+#include <linux/platform_device.h>
 #include <linux/leds.h>
 
 struct hswc_params {
@@ -124,19 +125,22 @@ static void asus_wireless_notify(acpi_handle handle, u32 event, void *context)
 	input_sync(data->idev);
 }
 
-static int asus_wireless_add(struct acpi_device *adev)
+static int asus_wireless_probe(struct platform_device *pdev)
 {
+	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
 	struct asus_wireless_data *data;
 	const struct acpi_device_id *id;
 	int err;
 
-	data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
-	adev->driver_data = data;
+
+	platform_set_drvdata(pdev, data);
+
 	data->adev = adev;
 
-	data->idev = devm_input_allocate_device(&adev->dev);
+	data->idev = devm_input_allocate_device(&pdev->dev);
 	if (!data->idev)
 		return -ENOMEM;
 	data->idev->name = "Asus Wireless Radio Control";
@@ -165,14 +169,14 @@ static int asus_wireless_add(struct acpi_device *adev)
 	data->led.flags = LED_CORE_SUSPENDRESUME;
 	data->led.max_brightness = 1;
 	data->led.default_trigger = "rfkill-none";
-	err = devm_led_classdev_register(&adev->dev, &data->led);
+	err = devm_led_classdev_register(&pdev->dev, &data->led);
 	if (err)
 		goto err;
 
 	err = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
 					      asus_wireless_notify, data);
 	if (err) {
-		devm_led_classdev_unregister(&adev->dev, &data->led);
+		devm_led_classdev_unregister(&pdev->dev, &data->led);
 		goto err;
 	}
 	return 0;
@@ -182,28 +186,27 @@ static int asus_wireless_add(struct acpi_device *adev)
 	return err;
 }
 
-static void asus_wireless_remove(struct acpi_device *adev)
+static void asus_wireless_remove(struct platform_device *pdev)
 {
-	struct asus_wireless_data *data = acpi_driver_data(adev);
+	struct asus_wireless_data *data = platform_get_drvdata(pdev);
 
-	acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+	acpi_dev_remove_notify_handler(data->adev, ACPI_DEVICE_NOTIFY,
 				       asus_wireless_notify);
 	if (data->wq) {
-		devm_led_classdev_unregister(&adev->dev, &data->led);
+		devm_led_classdev_unregister(&pdev->dev, &data->led);
 		destroy_workqueue(data->wq);
 	}
 }
 
-static struct acpi_driver asus_wireless_driver = {
-	.name = "Asus Wireless Radio Control Driver",
-	.class = "hotkey",
-	.ids = device_ids,
-	.ops = {
-		.add = asus_wireless_add,
-		.remove = asus_wireless_remove,
+static struct platform_driver asus_wireless_driver = {
+	.probe = asus_wireless_probe,
+	.remove = asus_wireless_remove,
+	.driver = {
+		.name = "Asus Wireless Radio Control Driver",
+		.acpi_match_table = device_ids,
 	},
 };
-module_acpi_driver(asus_wireless_driver);
+module_platform_driver(asus_wireless_driver);
 
 MODULE_DESCRIPTION("Asus Wireless Radio Control Driver");
 MODULE_AUTHOR("João Paulo Rechi Vita <[email protected]>");
maintainer
#13 lore raw

Re: [PATCH v1 4/4] platform/x86: asus-wireless: Convert ACPI driver to a platform one

In reply to Rafael J. Wysocki
Quoted 69 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

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

After this change, the subordinate input and LED devices 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.

---
 drivers/platform/x86/asus-wireless.c | 39 +++++++++++++++-------------
 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/platform/x86/asus-wireless.c +8 -4
index 45d41875c515..2b494bf3cba8 100644
@@ -12,6 +12,7 @@
 #include <linux/acpi.h>
 #include <linux/input.h>
 #include <linux/pci_ids.h>
+#include <linux/platform_device.h>
 #include <linux/leds.h>
 
 struct hswc_params {
@@ -124,19 +125,22 @@ static void asus_wireless_notify(acpi_handle handle, u32 event, void *context)
 	input_sync(data->idev);
 }
 
-static int asus_wireless_add(struct acpi_device *adev)
+static int asus_wireless_probe(struct platform_device *pdev)
 {
+	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
 	struct asus_wireless_data *data;
 	const struct acpi_device_id *id;
 	int err;
 
-	data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
-	adev->driver_data = data;
+
+	platform_set_drvdata(pdev, data);
+
 	data->adev = adev;
 
-	data->idev = devm_input_allocate_device(&adev->dev);
+	data->idev = devm_input_allocate_device(&pdev->dev);
 	if (!data->idev)
 		return -ENOMEM;
 	data->idev->name = "Asus Wireless Radio Control";
@@ -165,14 +169,14 @@ static int asus_wireless_add(struct acpi_device *adev)
 	data->led.flags = LED_CORE_SUSPENDRESUME;
 	data->led.max_brightness = 1;
 	data->led.default_trigger = "rfkill-none";

drivers/platform/x86/asus-wireless.c static int asus_wireless_add(struct acpi_device *adev) · line 179

Quoted 10 lines
drivers/platform/x86/asus-wireless.c +2 -2
-	err = devm_led_classdev_register(&adev->dev, &data->led);
+	err = devm_led_classdev_register(&pdev->dev, &data->led);
 	if (err)
 		goto err;
 
 	err = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
 					      asus_wireless_notify, data);
 	if (err) {
-		devm_led_classdev_unregister(&adev->dev, &data->led);
+		devm_led_classdev_unregister(&pdev->dev, &data->led);

I've taken this series now into the review-ilpo-next branch.

However, here are manual devm_*() rollbacks which could probably be eliminated as well but you can do them on top of this.

--
i.

Quoted 44 lines
drivers/platform/x86/asus-wireless.c +11 -12
 		goto err;
 	}
 	return 0;
@@ -182,28 +186,27 @@ static int asus_wireless_add(struct acpi_device *adev)
 	return err;
 }
 
-static void asus_wireless_remove(struct acpi_device *adev)
+static void asus_wireless_remove(struct platform_device *pdev)
 {
-	struct asus_wireless_data *data = acpi_driver_data(adev);
+	struct asus_wireless_data *data = platform_get_drvdata(pdev);
 
-	acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+	acpi_dev_remove_notify_handler(data->adev, ACPI_DEVICE_NOTIFY,
 				       asus_wireless_notify);
 	if (data->wq) {
-		devm_led_classdev_unregister(&adev->dev, &data->led);
+		devm_led_classdev_unregister(&pdev->dev, &data->led);
 		destroy_workqueue(data->wq);
 	}
 }
 
-static struct acpi_driver asus_wireless_driver = {
-	.name = "Asus Wireless Radio Control Driver",
-	.class = "hotkey",
-	.ids = device_ids,
-	.ops = {
-		.add = asus_wireless_add,
-		.remove = asus_wireless_remove,
+static struct platform_driver asus_wireless_driver = {
+	.probe = asus_wireless_probe,
+	.remove = asus_wireless_remove,
+	.driver = {
+		.name = "Asus Wireless Radio Control Driver",
+		.acpi_match_table = device_ids,
 	},
 };
-module_acpi_driver(asus_wireless_driver);
+module_platform_driver(asus_wireless_driver);
 
 MODULE_DESCRIPTION("Asus Wireless Radio Control Driver");
 MODULE_AUTHOR("João Paulo Rechi Vita <[email protected]>");