Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Armin Wolf and committed by
Ilpo Järvinen
7e2d964f 0ec7f158

+49 -1
+2 -1
Documentation/wmi/driver-development-guide.rst
··· 106 106 107 107 WMI drivers can call WMI device methods using wmidev_invoke_method(). For each WMI method 108 108 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. 110 111 111 112 The layout of said buffers is device-specific and described by the Binary MOF data associated 112 113 with a given WMI device. Said Binary MOF data also describes the method ID of a given WMI method
+44
drivers/platform/wmi/core.c
··· 427 427 } 428 428 EXPORT_SYMBOL_GPL(wmidev_invoke_method); 429 429 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 + 430 474 static acpi_status __query_block(struct wmi_block *wblock, u8 instance, 431 475 struct acpi_buffer *out) 432 476 {
+3
include/linux/wmi.h
··· 70 70 int wmidev_invoke_method(struct wmi_device *wdev, u8 instance, u32 method_id, 71 71 const struct wmi_buffer *in, struct wmi_buffer *out); 72 72 73 + int wmidev_invoke_procedure(struct wmi_device *wdev, u8 instance, u32 method_id, 74 + const struct wmi_buffer *in); 75 + 73 76 int wmidev_query_block(struct wmi_device *wdev, u8 instance, struct wmi_buffer *out); 74 77 75 78 int wmidev_set_block(struct wmi_device *wdev, u8 instance, const struct wmi_buffer *in);