public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Denis Benato <denis.benato@linux.dev>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: "Hans de Goede" <hansg@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Linux ACPI" <linux-acpi@vger.kernel.org>,
	platform-driver-x86@vger.kernel.org,
	"Corentin Chary" <corentin.chary@gmail.com>,
	"Luke D. Jones" <luke@ljones.dev>,
	"João Paulo Rechi Vita" <jprvita@gmail.com>
Subject: Re: [PATCH v1 4/4] platform/x86: asus-wireless: Convert ACPI driver to a platform one
Date: Sat, 28 Feb 2026 18:02:46 +0100	[thread overview]
Message-ID: <b3a0b70c-20cb-4c7a-837a-79a5f756d017@linux.dev> (raw)
In-Reply-To: <13959361.uLZWGnKmhe@rafael.j.wysocki>


On 2/28/26 16:12, Rafael J. Wysocki 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 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.
>
> Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Denis Benato <denis.benato@linux.dev>
> ---
>  drivers/platform/x86/asus-wireless.c | 39 +++++++++++++++-------------
>  1 file changed, 21 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c
> index 45d41875c515..2b494bf3cba8 100644
> --- a/drivers/platform/x86/asus-wireless.c
> +++ b/drivers/platform/x86/asus-wireless.c
> @@ -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 <jprvita@gmail.com>");

      reply	other threads:[~2026-02-28 17:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-28 15:09 [PATCH v1 0/4] platform/x86: asus: Bind drivers to platform devices instead of ACPI ones Rafael J. Wysocki
2026-02-28 15:10 ` [PATCH v1 1/4] platform/x86: asus-laptop: Register ACPI notify handler directly Rafael J. Wysocki
2026-02-28 16:59   ` Denis Benato
2026-02-28 15:11 ` [PATCH v1 2/4] platform/x86: asus-laptop: Convert ACPI driver to a platform one Rafael J. Wysocki
2026-02-28 17:01   ` Denis Benato
2026-03-01 13:08     ` Rafael J. Wysocki
2026-03-02 11:21     ` Ilpo Järvinen
2026-02-28 15:12 ` [PATCH v1 3/4] platform/x86: asus-wireless: Register ACPI notify handler directly Rafael J. Wysocki
2026-02-28 17:02   ` Denis Benato
2026-02-28 15:12 ` [PATCH v1 4/4] platform/x86: asus-wireless: Convert ACPI driver to a platform one Rafael J. Wysocki
2026-02-28 17:02   ` Denis Benato [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b3a0b70c-20cb-4c7a-837a-79a5f756d017@linux.dev \
    --to=denis.benato@linux.dev \
    --cc=corentin.chary@gmail.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jprvita@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luke@ljones.dev \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox