From: "Rafael J. Wysocki" <rafael@kernel.org>
To: "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
Subject: [PATCH v1 2/2] platform/x86: wireless-hotkey: Convert ACPI driver to a platform one
Date: Thu, 12 Mar 2026 15:40:36 +0100 [thread overview]
Message-ID: <9607409.CDJkKcVGEf@rafael.j.wysocki> (raw)
In-Reply-To: <23052072.EfDdHjke4D@rafael.j.wysocki>
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 airplane mode button for AMD, HP and
Xiaomi laptops 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/wireless-hotkey.c | 44 ++++++++++++++------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/drivers/platform/x86/wireless-hotkey.c b/drivers/platform/x86/wireless-hotkey.c
index a0ae757a277e..f680d8ff8e87 100644
--- a/drivers/platform/x86/wireless-hotkey.c
+++ b/drivers/platform/x86/wireless-hotkey.c
@@ -35,16 +35,17 @@ static const struct acpi_device_id wl_ids[] = {
{"", 0},
};
-static int wireless_input_setup(struct acpi_device *device)
+static int wireless_input_setup(struct device *dev)
{
- struct wl_button *button = acpi_driver_data(device);
+ struct wl_button *button = dev_get_drvdata(dev);
int err;
button->input_dev = input_allocate_device();
if (!button->input_dev)
return -ENOMEM;
- snprintf(button->phys, sizeof(button->phys), "%s/input0", acpi_device_hid(device));
+ snprintf(button->phys, sizeof(button->phys), "%s/input0",
+ acpi_device_hid(ACPI_COMPANION(dev)));
button->input_dev->name = "Wireless hotkeys";
button->input_dev->phys = button->phys;
@@ -63,9 +64,9 @@ static int wireless_input_setup(struct acpi_device *device)
return err;
}
-static void wireless_input_destroy(struct acpi_device *device)
+static void wireless_input_destroy(struct device *dev)
{
- struct wl_button *button = acpi_driver_data(device);
+ struct wl_button *button = dev_get_drvdata(dev);
input_unregister_device(button->input_dev);
kfree(button);
@@ -86,7 +87,7 @@ static void wl_notify(acpi_handle handle, u32 event, void *data)
input_sync(button->input_dev);
}
-static int wl_add(struct acpi_device *device)
+static int wl_probe(struct platform_device *pdev)
{
struct wl_button *button;
int err;
@@ -95,37 +96,38 @@ static int wl_add(struct acpi_device *device)
if (!button)
return -ENOMEM;
- device->driver_data = button;
+ platform_set_drvdata(pdev, button);
- err = wireless_input_setup(device);
+ err = wireless_input_setup(&pdev->dev);
if (err) {
pr_err("Failed to setup wireless hotkeys\n");
kfree(button);
return err;
}
- err = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
- wl_notify, button);
+ err = acpi_dev_install_notify_handler(ACPI_COMPANION(&pdev->dev),
+ ACPI_DEVICE_NOTIFY, wl_notify, button);
if (err) {
pr_err("Failed to install ACPI notify handler\n");
- wireless_input_destroy(device);
+ wireless_input_destroy(&pdev->dev);
}
return err;
}
-static void wl_remove(struct acpi_device *device)
+static void wl_remove(struct platform_device *pdev)
{
- acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, wl_notify);
- wireless_input_destroy(device);
+ acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
+ ACPI_DEVICE_NOTIFY, wl_notify);
+ wireless_input_destroy(&pdev->dev);
}
-static struct acpi_driver wl_driver = {
- .name = "wireless-hotkey",
- .ids = wl_ids,
- .ops = {
- .add = wl_add,
- .remove = wl_remove,
+static struct platform_driver wl_driver = {
+ .probe = wl_probe,
+ .remove = wl_remove,
+ .driver = {
+ .name = "wireless-hotkey",
+ .acpi_match_table = wl_ids,
},
};
-module_acpi_driver(wl_driver);
+module_platform_driver(wl_driver);
--
2.51.0
next prev parent reply other threads:[~2026-03-12 14:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 14:37 [PATCH v1 0/2] platform/x86: wireless-hotkey: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
2026-03-12 14:38 ` [PATCH v1 1/2] platform/x86: wireless-hotkey: Register ACPI notify handler directly Rafael J. Wysocki
2026-03-12 14:40 ` Rafael J. Wysocki [this message]
2026-03-17 18:08 ` [PATCH v1 0/2] platform/x86: wireless-hotkey: Bind to a platform device instead of an ACPI one Ilpo Järvinen
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=9607409.CDJkKcVGEf@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.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