From: Armin Wolf <W_Armin@gmx.de>
To: hansg@kernel.org
Cc: ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/6] platform/wmi: Add wmidev_invoke_procedure()
Date: Mon, 6 Apr 2026 22:32:32 +0200 [thread overview]
Message-ID: <20260406203237.2970-2-W_Armin@gmx.de> (raw)
In-Reply-To: <20260406203237.2970-1-W_Armin@gmx.de>
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>
---
.../wmi/driver-development-guide.rst | 3 +-
drivers/platform/wmi/core.c | 44 +++++++++++++++++++
include/linux/wmi.h | 3 ++
3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/Documentation/wmi/driver-development-guide.rst b/Documentation/wmi/driver-development-guide.rst
index fbc2d9b12fe9..5b94402874c4 100644
--- a/Documentation/wmi/driver-development-guide.rst
+++ b/Documentation/wmi/driver-development-guide.rst
@@ -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
diff --git a/drivers/platform/wmi/core.c b/drivers/platform/wmi/core.c
index b8e6b9a421c6..7cc5ca11a60d 100644
--- a/drivers/platform/wmi/core.c
+++ b/drivers/platform/wmi/core.c
@@ -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)
{
diff --git a/include/linux/wmi.h b/include/linux/wmi.h
index 75cb0c7cfe57..b00950dc1231 100644
--- a/include/linux/wmi.h
+++ b/include/linux/wmi.h
@@ -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);
--
2.39.5
next prev parent reply other threads:[~2026-04-06 21:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-06 20:32 [PATCH 0/6] platform/wmi: Use WMI driver core for size checks Armin Wolf
2026-04-06 20:32 ` Armin Wolf [this message]
2026-04-06 20:32 ` [PATCH 2/6] platform/wmi: Convert drivers to use wmidev_invoke_procedure() Armin Wolf
2026-04-06 20:32 ` [PATCH 3/6] platform/wmi: Prepare to reject undersized unmarshalling results Armin Wolf
2026-04-06 20:32 ` [PATCH 4/6] platform/wmi: Extend wmidev_invoke_method() to reject undersized data Armin Wolf
2026-04-06 20:32 ` [PATCH 5/6] platform/wmi: Extend wmidev_query_block() " Armin Wolf
2026-04-06 20:32 ` [PATCH 6/6] platform/wmi: Replace .no_notify_data with .min_event_size Armin Wolf
2026-04-10 16:28 ` [PATCH 0/6] platform/wmi: Use WMI driver core for size checks Ilpo Järvinen
2026-04-13 6:20 ` 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=20260406203237.2970-2-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/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
all inboxes | Powered by JetHome®