platform/x86: alienware-wmi-base: Transition to new WMI API
Subsystems (2)
Kurt Borja
maintainerPATCH v3 1/1 platform/x86: alienware-wmi-base: Transition to new WMI API
Transition to the new wmi_buffer based WMI API.
---
v3:
- Use __free() instead of manual cleanup.
- Include <linux/types.h>
v2: https://patch.msgid.link/[email protected]
- Cast wmi_buffer data to __le32 and then use le32_to_cpu() before returning
v1: https://patch.msgid.link/[email protected]
--- drivers/platform/x86/dell/alienware-wmi-base.c | 34 ++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-)
drivers/platform/x86/dell/alienware-wmi-base.c +21 -13
@@ -12,8 +12,13 @@#include <linux/cleanup.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/types.h> #include <linux/dmi.h> #include <linux/leds.h> + +#include <asm/byteorder.h> +#include "alienware-wmi.h" MODULE_AUTHOR ("Mario Limonciello <[email protected]>" );
@@ -150,22 +155,25 @@ u8 alienware_interface;int alienware_wmi_command (struct wmi_device *wdev,u32 method_id,void *in_args,size_t in_size,u32 *out_data) { -struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER ,NULL }; -struct acpi_buffer in = {in_size, in_args}; -acpi_status ret; +struct wmi_buffer out, in = { + .data = in_args, + .length = in_size, + }; +int ret; - ret =wmidev_evaluate_method (wdev,0 , method_id, &in, out_data ? &out :NULL ); -if (ACPI_FAILURE (ret)) -return -EIO ; + ret =wmidev_invoke_method (wdev,0 , method_id, &in, out_data ? &out :NULL ); +if (ret) +return ret; - union acpi_object *obj __free(kfree) = out.pointer; +if (!out_data) +return 0 ; -if (out_data) { -if (obj && obj->type ==ACPI_TYPE_INTEGER ) - *out_data = (u32 )obj->integer.value; -else -return -ENOMSG ; - } + __le32 *data __free(kfree) = out.data; + +if (out.length <sizeof (*out_data)) +return -ENOMSG ; + + *out_data =le32_to_cpu (*data);return 0 ; }
---
base-commit: fab7c51693e95aa874d6d9db22bfae7bd0b23c66
change-id: 20260123-aw-new-api-1c18f1011f35
Signature · 2 lines
Thanks, ~ Kurt
Am 31.03.26 um 18:20 schrieb Kurt Borja:
Quoted 1 line
Transition to the new
wmi_bufferbased WMI API.
Hi,
i think you will have to adapt this patch to the changes i made to wmidev_invoke_method(). Said function now takes an additional parameter specifying the minimum size of the output data.
In your case this would replace the size check when output data is expected, otherwise you should call wmidev_invoke_procedure.
Thanks,
Armin Wolf
Quoted 78 lines
Signed-off-by Kurt Borja <[email protected]>---
v3:
- Use__free()instead of manual cleanup.
- Include <linux/types.h>v2: https://patch.msgid.link/[email protected]
- Castwmi_bufferdata to__le32and then usele32_to_cpu()before returningv1: https://patch.msgid.link/[email protected]
--- drivers/platform/x86/dell/alienware-wmi-base.c | 34 ++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-)drivers/platform/x86/dell/alienware-wmi-base.c +21
-14@@ -12,8 +12,13 @@#include <linux/cleanup.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/types.h> #include <linux/dmi.h> #include <linux/leds.h> + +#include <asm/byteorder.h> +#include "alienware-wmi.h" MODULE_AUTHOR ("Mario Limonciello <[email protected]>" );@@ -150,22 +155,25 @@ u8 alienware_interface;int alienware_wmi_command (struct wmi_device *wdev,u32 method_id,void *in_args,size_t in_size,u32 *out_data) { -struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER ,NULL }; -struct acpi_buffer in = {in_size, in_args}; -acpi_status ret; +struct wmi_buffer out, in = { + .data = in_args, + .length = in_size, + }; +int ret; - ret =wmidev_evaluate_method (wdev,0 , method_id, &in, out_data ? &out :NULL ); -if (ACPI_FAILURE (ret)) -return -EIO ; + ret =wmidev_invoke_method (wdev,0 , method_id, &in, out_data ? &out :NULL ); +if (ret) +return ret; - union acpi_object *obj __free(kfree) = out.pointer; +if (!out_data) +return 0 ; -if (out_data) { -if (obj && obj->type ==ACPI_TYPE_INTEGER ) - *out_data = (u32 )obj->integer.value; -else -return -ENOMSG ; - } + __le32 *data __free(kfree) = out.data; + +if (out.length <sizeof (*out_data)) +return -ENOMSG ; + + *out_data =le32_to_cpu (*data);return 0 ; } ---base-commit:
fab7c51693e95aa874d6d9db22bfae7bd0b23c66
change-id: 20260123-aw-new-api-1c18f1011f35
Kurt Borja
maintainerQuoted 8 lines · Armin Wolf
Am 31.03.26 um 18:20 schrieb Kurt Borja:
Quoted 1 line
Transition to the new
wmi_bufferbased WMI API.Hi,
i think you will have to adapt this patch to the changes i made to
wmidev_invoke_method(). Said function now takes an additional parameter specifying the minimum size of the output data.
Hi Armin,
I'll go for this!
Quoted 6 lines
In your case this would replace the size check when output data is expected, otherwise you should call
wmidev_invoke_procedure.Thanks,
Armin Wolf