Skip to content

Commit 7e2d964

Browse files
Wer-Wolfij-intel
authored andcommitted
platform/wmi: Add wmidev_invoke_procedure()
Some WMI methods return no values, so the whole postprocessing of the result data is not needed for them. Add a special function for calling such WMI methods to prepare for future changes of the main wmidev_invoke_method() function. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://patch.msgid.link/20260406203237.2970-2-W_Armin@gmx.de Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 0ec7f15 commit 7e2d964

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

Documentation/wmi/driver-development-guide.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ WMI method drivers
106106

107107
WMI drivers can call WMI device methods using wmidev_invoke_method(). For each WMI method
108108
invocation the WMI driver needs to provide the instance number and the method ID, as well as
109-
a buffer with the method arguments and optionally a buffer for the results.
109+
a buffer with the method arguments and optionally a buffer for the results. When calling WMI
110+
methods that do not return any values, wmidev_invoke_procedure() should be used instead.
110111

111112
The layout of said buffers is device-specific and described by the Binary MOF data associated
112113
with a given WMI device. Said Binary MOF data also describes the method ID of a given WMI method

drivers/platform/wmi/core.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,50 @@ int wmidev_invoke_method(struct wmi_device *wdev, u8 instance, u32 method_id,
427427
}
428428
EXPORT_SYMBOL_GPL(wmidev_invoke_method);
429429

430+
/**
431+
* wmidev_invoke_procedure - Invoke a WMI method that does not return values
432+
* @wdev: A wmi bus device from a driver
433+
* @instance: Instance index
434+
* @method_id: Method ID to call
435+
* @in: Mandatory WMI buffer containing input for the method call
436+
*
437+
* Invoke a WMI method that does not return any values. Use wmidev_invoke_method()
438+
* for WMI methods that do return values.
439+
*
440+
* Return: 0 on success or negative error code on failure.
441+
*/
442+
int wmidev_invoke_procedure(struct wmi_device *wdev, u8 instance, u32 method_id,
443+
const struct wmi_buffer *in)
444+
{
445+
struct wmi_block *wblock = container_of(wdev, struct wmi_block, dev);
446+
struct acpi_buffer ain;
447+
acpi_status status;
448+
int ret;
449+
450+
if (wblock->gblock.flags & ACPI_WMI_STRING) {
451+
ret = wmi_marshal_string(in, &ain);
452+
if (ret < 0)
453+
return ret;
454+
} else {
455+
if (in->length > U32_MAX)
456+
return -E2BIG;
457+
458+
ain.length = in->length;
459+
ain.pointer = in->data;
460+
}
461+
462+
status = wmidev_evaluate_method(wdev, instance, method_id, &ain, NULL);
463+
464+
if (wblock->gblock.flags & ACPI_WMI_STRING)
465+
kfree(ain.pointer);
466+
467+
if (ACPI_FAILURE(status))
468+
return -EIO;
469+
470+
return 0;
471+
}
472+
EXPORT_SYMBOL_GPL(wmidev_invoke_procedure);
473+
430474
static acpi_status __query_block(struct wmi_block *wblock, u8 instance,
431475
struct acpi_buffer *out)
432476
{

include/linux/wmi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ ssize_t wmi_string_from_utf8s(struct wmi_string *str, size_t max_chars, const u8
7070
int wmidev_invoke_method(struct wmi_device *wdev, u8 instance, u32 method_id,
7171
const struct wmi_buffer *in, struct wmi_buffer *out);
7272

73+
int wmidev_invoke_procedure(struct wmi_device *wdev, u8 instance, u32 method_id,
74+
const struct wmi_buffer *in);
75+
7376
int wmidev_query_block(struct wmi_device *wdev, u8 instance, struct wmi_buffer *out);
7477

7578
int wmidev_set_block(struct wmi_device *wdev, u8 instance, const struct wmi_buffer *in);

0 commit comments

Comments
 (0)