]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/wmi: Add wmidev_invoke_procedure()
authorArmin Wolf <W_Armin@gmx.de>
Mon, 6 Apr 2026 20:32:32 +0000 (22:32 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 13 Apr 2026 11:11:18 +0000 (14:11 +0300)
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>
Documentation/wmi/driver-development-guide.rst
drivers/platform/wmi/core.c
include/linux/wmi.h

index fbc2d9b12fe9f8f7ef3a4ca0ac7b0d681fc5843b..5b94402874c4f5c6bc79865a32cedc02d94a62bb 100644 (file)
@@ -106,7 +106,8 @@ WMI method drivers
 
 WMI drivers can call WMI device methods using wmidev_invoke_method(). For each WMI method
 invocation the WMI driver needs to provide the instance number and the method ID, as well as
-a buffer with the method arguments and optionally a buffer for the results.
+a buffer with the method arguments and optionally a buffer for the results. When calling WMI
+methods that do not return any values, wmidev_invoke_procedure() should be used instead.
 
 The layout of said buffers is device-specific and described by the Binary MOF data associated
 with a given WMI device. Said Binary MOF data also describes the method ID of a given WMI method
index b8e6b9a421c6272d1b42556888c616b583ed5b72..7cc5ca11a60d067b125ca00608827885a35adc5d 100644 (file)
@@ -427,6 +427,50 @@ int wmidev_invoke_method(struct wmi_device *wdev, u8 instance, u32 method_id,
 }
 EXPORT_SYMBOL_GPL(wmidev_invoke_method);
 
+/**
+ * wmidev_invoke_procedure - Invoke a WMI method that does not return values
+ * @wdev: A wmi bus device from a driver
+ * @instance: Instance index
+ * @method_id: Method ID to call
+ * @in: Mandatory WMI buffer containing input for the method call
+ *
+ * Invoke a WMI method that does not return any values. Use wmidev_invoke_method()
+ * for WMI methods that do return values.
+ *
+ * Return: 0 on success or negative error code on failure.
+ */
+int wmidev_invoke_procedure(struct wmi_device *wdev, u8 instance, u32 method_id,
+                           const struct wmi_buffer *in)
+{
+       struct wmi_block *wblock = container_of(wdev, struct wmi_block, dev);
+       struct acpi_buffer ain;
+       acpi_status status;
+       int ret;
+
+       if (wblock->gblock.flags & ACPI_WMI_STRING) {
+               ret = wmi_marshal_string(in, &ain);
+               if (ret < 0)
+                       return ret;
+       } else {
+               if (in->length > U32_MAX)
+                       return -E2BIG;
+
+               ain.length = in->length;
+               ain.pointer = in->data;
+       }
+
+       status = wmidev_evaluate_method(wdev, instance, method_id, &ain, NULL);
+
+       if (wblock->gblock.flags & ACPI_WMI_STRING)
+               kfree(ain.pointer);
+
+       if (ACPI_FAILURE(status))
+               return -EIO;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(wmidev_invoke_procedure);
+
 static acpi_status __query_block(struct wmi_block *wblock, u8 instance,
                                 struct acpi_buffer *out)
 {
index 75cb0c7cfe57135ef9b0589d71be89a2d55e407b..b00950dc1231ac3c95126423698994b80e4cd4c4 100644 (file)
@@ -70,6 +70,9 @@ ssize_t wmi_string_from_utf8s(struct wmi_string *str, size_t max_chars, const u8
 int wmidev_invoke_method(struct wmi_device *wdev, u8 instance, u32 method_id,
                         const struct wmi_buffer *in, struct wmi_buffer *out);
 
+int wmidev_invoke_procedure(struct wmi_device *wdev, u8 instance, u32 method_id,
+                           const struct wmi_buffer *in);
+
 int wmidev_query_block(struct wmi_device *wdev, u8 instance, struct wmi_buffer *out);
 
 int wmidev_set_block(struct wmi_device *wdev, u8 instance, const struct wmi_buffer *in);