From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Armin Wolf <W_Armin@gmx.de>
Cc: Dell.Client.Kernel@dell.com, pali@kernel.org,
mjg59@srcf.ucam.org, soyer@irl.hu,
Hans de Goede <hansg@kernel.org>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
linux@roeck-us.net, linux-hwmon@vger.kernel.org,
mario.limonciello@amd.com
Subject: Re: [PATCH v5 4/9] platform/x86: dell-wmi-base: Use new buffer-based WMI API
Date: Tue, 9 Jun 2026 14:16:58 +0300 (EEST) [thread overview]
Message-ID: <a669374c-2c00-f7f2-2dda-321e58024a31@linux.intel.com> (raw)
In-Reply-To: <20260605205937.530897-5-W_Armin@gmx.de>
On Fri, 5 Jun 2026, Armin Wolf wrote:
> Use the new buffer-based WMI API to also support ACPI firmware
> implementations that do not use ACPI buffers for the event data.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> drivers/platform/x86/dell/dell-wmi-base.c | 70 ++++++++++++-----------
> 1 file changed, 36 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/dell-wmi-base.c b/drivers/platform/x86/dell/dell-wmi-base.c
> index 2a5804efd3ea..1070df065807 100644
> --- a/drivers/platform/x86/dell/dell-wmi-base.c
> +++ b/drivers/platform/x86/dell/dell-wmi-base.c
> @@ -13,6 +13,7 @@
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> +#include <linux/compiler_attributes.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/init.h>
> @@ -414,7 +415,8 @@ static void dell_wmi_switch_event(struct input_dev **subdev,
> input_sync(*subdev);
> }
>
> -static int dell_wmi_process_key(struct wmi_device *wdev, int type, int code, u16 *buffer, int remaining)
> +static int dell_wmi_process_key(struct wmi_device *wdev, int type, int code, __le16 *buffer,
> + int remaining)
> {
> struct dell_wmi_priv *priv = dev_get_drvdata(&wdev->dev);
> const struct key_entry *key;
> @@ -446,15 +448,15 @@ static int dell_wmi_process_key(struct wmi_device *wdev, int type, int code, u16
> } else if (type == 0x0011 && code == 0xe070 && remaining > 0) {
> dell_wmi_switch_event(&priv->tabletswitch_dev,
> "Dell tablet mode switch",
> - SW_TABLET_MODE, !buffer[0]);
> + SW_TABLET_MODE, !le16_to_cpu(buffer[0]));
> return 1;
> } else if (type == 0x0012 && code == 0x000c && remaining > 0) {
> /* Eprivacy toggle, switch to "on" key entry for on events */
> - if (buffer[0] == 2)
> + if (le16_to_cpu(buffer[0]) == 2)
> key++;
> used = 1;
> } else if (type == 0x0012 && code == 0x000d && remaining > 0) {
> - value = (buffer[2] == 2);
> + value = (le16_to_cpu(buffer[2]) == 2);
> used = 1;
> }
>
> @@ -463,24 +465,17 @@ static int dell_wmi_process_key(struct wmi_device *wdev, int type, int code, u16
> return used;
> }
>
> -static void dell_wmi_notify(struct wmi_device *wdev,
> - union acpi_object *obj)
> +static void dell_wmi_notify(struct wmi_device *wdev, const struct wmi_buffer *buffer)
> {
> struct dell_wmi_priv *priv = dev_get_drvdata(&wdev->dev);
> - u16 *buffer_entry, *buffer_end;
> - acpi_size buffer_size;
> + __le16 *buffer_entry, *buffer_end;
> + size_t buffer_size;
> int len, i;
>
> - if (obj->type != ACPI_TYPE_BUFFER) {
> - pr_warn("bad response type %x\n", obj->type);
> - return;
> - }
> + pr_debug("Received WMI event (%*ph)\n", (int)buffer->length, buffer->data);
>
> - pr_debug("Received WMI event (%*ph)\n",
> - obj->buffer.length, obj->buffer.pointer);
> -
> - buffer_entry = (u16 *)obj->buffer.pointer;
> - buffer_size = obj->buffer.length/2;
> + buffer_entry = buffer->data;
> + buffer_size = buffer->length / 2;
> buffer_end = buffer_entry + buffer_size;
>
> /*
> @@ -496,12 +491,12 @@ static void dell_wmi_notify(struct wmi_device *wdev,
> * one event on devices with WMI interface version 0.
> */
> if (priv->interface_version == 0 && buffer_entry < buffer_end)
> - if (buffer_end > buffer_entry + buffer_entry[0] + 1)
> - buffer_end = buffer_entry + buffer_entry[0] + 1;
> + if (buffer_end > buffer_entry + le16_to_cpu(buffer_entry[0]) + 1)
> + buffer_end = buffer_entry + le16_to_cpu(buffer_entry[0]) + 1;
>
> while (buffer_entry < buffer_end) {
>
> - len = buffer_entry[0];
> + len = le16_to_cpu(buffer_entry[0]);
> if (len == 0)
> break;
>
> @@ -514,11 +509,11 @@ static void dell_wmi_notify(struct wmi_device *wdev,
>
> pr_debug("Process buffer (%*ph)\n", len*2, buffer_entry);
>
> - switch (buffer_entry[1]) {
> + switch (le16_to_cpu(buffer_entry[1])) {
> case 0x0000: /* One key pressed or event occurred */
> if (len > 2)
> - dell_wmi_process_key(wdev, buffer_entry[1],
> - buffer_entry[2],
> + dell_wmi_process_key(wdev, le16_to_cpu(buffer_entry[1]),
> + le16_to_cpu(buffer_entry[2]),
> buffer_entry + 3,
> len - 3);
> /* Extended data is currently ignored */
> @@ -526,22 +521,29 @@ static void dell_wmi_notify(struct wmi_device *wdev,
> case 0x0010: /* Sequence of keys pressed */
> case 0x0011: /* Sequence of events occurred */
> for (i = 2; i < len; ++i)
> - i += dell_wmi_process_key(wdev, buffer_entry[1],
> - buffer_entry[i],
> + i += dell_wmi_process_key(wdev, le16_to_cpu(buffer_entry[1]),
> + le16_to_cpu(buffer_entry[i]),
> buffer_entry + i,
> len - i - 1);
> break;
> case 0x0012:
> - if ((len > 4) && dell_privacy_process_event(buffer_entry[1], buffer_entry[3],
> - buffer_entry[4]))
> - /* dell_privacy_process_event has handled the event */;
> - else if (len > 2)
> - dell_wmi_process_key(wdev, buffer_entry[1], buffer_entry[2],
> + if (len > 4) {
> + if (dell_privacy_process_event(le16_to_cpu(buffer_entry[1]),
> + le16_to_cpu(buffer_entry[3]),
> + le16_to_cpu(buffer_entry[4])))
> + break;
> + }
> +
> + /* dell_privacy_process_event has not handled the event */
> +
> + if (len > 2)
Please refactor the logic in separate patch.
> + dell_wmi_process_key(wdev, le16_to_cpu(buffer_entry[1]),
> + le16_to_cpu(buffer_entry[2]),
> buffer_entry + 3, len - 3);
> +
> break;
> default: /* Unknown event */
> - pr_info("Unknown WMI event type 0x%x\n",
> - (int)buffer_entry[1]);
> + pr_info("Unknown WMI event type 0x%x\n", le16_to_cpu(buffer_entry[1]));
> break;
> }
>
> @@ -825,10 +827,10 @@ static struct wmi_driver dell_wmi_driver = {
> .name = "dell-wmi",
> },
> .id_table = dell_wmi_id_table,
> - .min_event_size = sizeof(u16),
> + .min_event_size = sizeof(__le16),
> .probe = dell_wmi_probe,
> .remove = dell_wmi_remove,
> - .notify = dell_wmi_notify,
> + .notify_new = dell_wmi_notify,
> };
>
> static int __init dell_wmi_init(void)
>
--
i.
next prev parent reply other threads:[~2026-06-09 11:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 20:59 [PATCH v5 0/9] Convert most Dell WMI drivers to use the new buffer-based API Armin Wolf
2026-06-05 20:59 ` [PATCH v5 1/9] platform/x86: dell-descriptor: Use new buffer-based WMI API Armin Wolf
2026-06-09 10:58 ` Ilpo Järvinen
2026-06-05 20:59 ` [PATCH v5 2/9] platform/x86: dell-privacy: " Armin Wolf
2026-06-05 20:59 ` [PATCH v5 3/9] platform/x86: dell-smbios-wmi: " Armin Wolf
2026-06-05 20:59 ` [PATCH v5 4/9] platform/x86: dell-wmi-base: " Armin Wolf
2026-06-09 11:16 ` Ilpo Järvinen [this message]
2026-06-05 20:59 ` [PATCH v5 5/9] platform/x86: dell-ddv: " Armin Wolf
2026-06-05 20:59 ` [PATCH v5 6/9] hwmon: (dell-smm) " Armin Wolf
2026-06-09 11:32 ` Ilpo Järvinen
2026-06-05 20:59 ` [PATCH v5 7/9] platform/wmi: Make wmi_bus_class const Armin Wolf
2026-06-09 11:33 ` Ilpo Järvinen
2026-06-05 20:59 ` [PATCH v5 8/9] platform/wmi: Make sysfs attributes const Armin Wolf
2026-06-09 11:34 ` Ilpo Järvinen
2026-06-05 20:59 ` [PATCH v5 9/9] modpost: Handle malformed WMI GUID strings Armin Wolf
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=a669374c-2c00-f7f2-2dda-321e58024a31@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Dell.Client.Kernel@dell.com \
--cc=W_Armin@gmx.de \
--cc=hansg@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mario.limonciello@amd.com \
--cc=mjg59@srcf.ucam.org \
--cc=pali@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=soyer@irl.hu \
/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
Powered by JetHome