* [PATCH] platform/x86: wireless-hotkey: use ACPI HID as phys
@ 2022-11-27 0:46 Alex Hung
2022-12-08 10:46 ` Hans de Goede
0 siblings, 1 reply; 2+ messages in thread
From: Alex Hung @ 2022-11-27 0:46 UTC (permalink / raw)
To: hdegoede, markgross, platform-driver-x86; +Cc: Alex Hung
From: Alex Hung <alexhung@gmail.com>
Removed the hardcoded "hpq6001" as phys but uses ACPI HID instead.
Signed-off-by: Alex Hung <alexhung@gmail.com>
---
drivers/platform/x86/wireless-hotkey.c | 60 +++++++++++++++++---------
1 file changed, 40 insertions(+), 20 deletions(-)
diff --git a/drivers/platform/x86/wireless-hotkey.c b/drivers/platform/x86/wireless-hotkey.c
index 11c60a273446..eb48ca060bad 100644
--- a/drivers/platform/x86/wireless-hotkey.c
+++ b/drivers/platform/x86/wireless-hotkey.c
@@ -20,7 +20,10 @@ MODULE_ALIAS("acpi*:HPQ6001:*");
MODULE_ALIAS("acpi*:WSTADEF:*");
MODULE_ALIAS("acpi*:AMDI0051:*");
-static struct input_dev *wl_input_dev;
+struct wl_button {
+ struct input_dev *input_dev;
+ char phys[32];
+};
static const struct acpi_device_id wl_ids[] = {
{"HPQ6001", 0},
@@ -29,63 +32,80 @@ static const struct acpi_device_id wl_ids[] = {
{"", 0},
};
-static int wireless_input_setup(void)
+static int wireless_input_setup(struct acpi_device *device)
{
+ struct wl_button *button = acpi_driver_data(device);
int err;
- wl_input_dev = input_allocate_device();
- if (!wl_input_dev)
+ button->input_dev = input_allocate_device();
+ if (!button->input_dev)
return -ENOMEM;
- wl_input_dev->name = "Wireless hotkeys";
- wl_input_dev->phys = "hpq6001/input0";
- wl_input_dev->id.bustype = BUS_HOST;
- wl_input_dev->evbit[0] = BIT(EV_KEY);
- set_bit(KEY_RFKILL, wl_input_dev->keybit);
+ snprintf(button->phys, sizeof(button->phys), "%s/input0", acpi_device_hid(device));
+
+ button->input_dev->name = "Wireless hotkeys";
+ button->input_dev->phys = button->phys;
+ button->input_dev->id.bustype = BUS_HOST;
+ button->input_dev->evbit[0] = BIT(EV_KEY);
+ set_bit(KEY_RFKILL, button->input_dev->keybit);
- err = input_register_device(wl_input_dev);
+ err = input_register_device(button->input_dev);
if (err)
goto err_free_dev;
return 0;
err_free_dev:
- input_free_device(wl_input_dev);
+ input_free_device(button->input_dev);
return err;
}
-static void wireless_input_destroy(void)
+static void wireless_input_destroy(struct acpi_device *device)
{
- input_unregister_device(wl_input_dev);
+ struct wl_button *button = acpi_driver_data(device);
+
+ input_unregister_device(button->input_dev);
+ kfree(button);
}
static void wl_notify(struct acpi_device *acpi_dev, u32 event)
{
+ struct wl_button *button = acpi_driver_data(acpi_dev);
+
if (event != 0x80) {
pr_info("Received unknown event (0x%x)\n", event);
return;
}
- input_report_key(wl_input_dev, KEY_RFKILL, 1);
- input_sync(wl_input_dev);
- input_report_key(wl_input_dev, KEY_RFKILL, 0);
- input_sync(wl_input_dev);
+ input_report_key(button->input_dev, KEY_RFKILL, 1);
+ input_sync(button->input_dev);
+ input_report_key(button->input_dev, KEY_RFKILL, 0);
+ input_sync(button->input_dev);
}
static int wl_add(struct acpi_device *device)
{
+ struct wl_button *button;
int err;
- err = wireless_input_setup();
- if (err)
+ button = kzalloc(sizeof(struct wl_button), GFP_KERNEL);
+ if (!button)
+ return -ENOMEM;
+
+ device->driver_data = button;
+
+ err = wireless_input_setup(device);
+ if (err) {
pr_err("Failed to setup wireless hotkeys\n");
+ kfree(button);
+ }
return err;
}
static int wl_remove(struct acpi_device *device)
{
- wireless_input_destroy();
+ wireless_input_destroy(device);
return 0;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/x86: wireless-hotkey: use ACPI HID as phys
2022-11-27 0:46 [PATCH] platform/x86: wireless-hotkey: use ACPI HID as phys Alex Hung
@ 2022-12-08 10:46 ` Hans de Goede
0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2022-12-08 10:46 UTC (permalink / raw)
To: Alex Hung, markgross, platform-driver-x86; +Cc: Alex Hung
Hi,
On 11/27/22 01:46, Alex Hung wrote:
> From: Alex Hung <alexhung@gmail.com>
>
> Removed the hardcoded "hpq6001" as phys but uses ACPI HID instead.
>
> Signed-off-by: Alex Hung <alexhung@gmail.com>
Thank you for your patch, I've applied this patch to my review-hans
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.
Regards,
Hans
> ---
> drivers/platform/x86/wireless-hotkey.c | 60 +++++++++++++++++---------
> 1 file changed, 40 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/platform/x86/wireless-hotkey.c b/drivers/platform/x86/wireless-hotkey.c
> index 11c60a273446..eb48ca060bad 100644
> --- a/drivers/platform/x86/wireless-hotkey.c
> +++ b/drivers/platform/x86/wireless-hotkey.c
> @@ -20,7 +20,10 @@ MODULE_ALIAS("acpi*:HPQ6001:*");
> MODULE_ALIAS("acpi*:WSTADEF:*");
> MODULE_ALIAS("acpi*:AMDI0051:*");
>
> -static struct input_dev *wl_input_dev;
> +struct wl_button {
> + struct input_dev *input_dev;
> + char phys[32];
> +};
>
> static const struct acpi_device_id wl_ids[] = {
> {"HPQ6001", 0},
> @@ -29,63 +32,80 @@ static const struct acpi_device_id wl_ids[] = {
> {"", 0},
> };
>
> -static int wireless_input_setup(void)
> +static int wireless_input_setup(struct acpi_device *device)
> {
> + struct wl_button *button = acpi_driver_data(device);
> int err;
>
> - wl_input_dev = input_allocate_device();
> - if (!wl_input_dev)
> + button->input_dev = input_allocate_device();
> + if (!button->input_dev)
> return -ENOMEM;
>
> - wl_input_dev->name = "Wireless hotkeys";
> - wl_input_dev->phys = "hpq6001/input0";
> - wl_input_dev->id.bustype = BUS_HOST;
> - wl_input_dev->evbit[0] = BIT(EV_KEY);
> - set_bit(KEY_RFKILL, wl_input_dev->keybit);
> + snprintf(button->phys, sizeof(button->phys), "%s/input0", acpi_device_hid(device));
> +
> + button->input_dev->name = "Wireless hotkeys";
> + button->input_dev->phys = button->phys;
> + button->input_dev->id.bustype = BUS_HOST;
> + button->input_dev->evbit[0] = BIT(EV_KEY);
> + set_bit(KEY_RFKILL, button->input_dev->keybit);
>
> - err = input_register_device(wl_input_dev);
> + err = input_register_device(button->input_dev);
> if (err)
> goto err_free_dev;
>
> return 0;
>
> err_free_dev:
> - input_free_device(wl_input_dev);
> + input_free_device(button->input_dev);
> return err;
> }
>
> -static void wireless_input_destroy(void)
> +static void wireless_input_destroy(struct acpi_device *device)
> {
> - input_unregister_device(wl_input_dev);
> + struct wl_button *button = acpi_driver_data(device);
> +
> + input_unregister_device(button->input_dev);
> + kfree(button);
> }
>
> static void wl_notify(struct acpi_device *acpi_dev, u32 event)
> {
> + struct wl_button *button = acpi_driver_data(acpi_dev);
> +
> if (event != 0x80) {
> pr_info("Received unknown event (0x%x)\n", event);
> return;
> }
>
> - input_report_key(wl_input_dev, KEY_RFKILL, 1);
> - input_sync(wl_input_dev);
> - input_report_key(wl_input_dev, KEY_RFKILL, 0);
> - input_sync(wl_input_dev);
> + input_report_key(button->input_dev, KEY_RFKILL, 1);
> + input_sync(button->input_dev);
> + input_report_key(button->input_dev, KEY_RFKILL, 0);
> + input_sync(button->input_dev);
> }
>
> static int wl_add(struct acpi_device *device)
> {
> + struct wl_button *button;
> int err;
>
> - err = wireless_input_setup();
> - if (err)
> + button = kzalloc(sizeof(struct wl_button), GFP_KERNEL);
> + if (!button)
> + return -ENOMEM;
> +
> + device->driver_data = button;
> +
> + err = wireless_input_setup(device);
> + if (err) {
> pr_err("Failed to setup wireless hotkeys\n");
> + kfree(button);
> + }
>
> return err;
> }
>
> static int wl_remove(struct acpi_device *device)
> {
> - wireless_input_destroy();
> + wireless_input_destroy(device);
> return 0;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-08 10:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-27 0:46 [PATCH] platform/x86: wireless-hotkey: use ACPI HID as phys Alex Hung
2022-12-08 10:46 ` Hans de Goede
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.