mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bartu Alev <bartualev@gmail.com>
To: "Corentin Chary" <corentin.chary@gmail.com>,
	"Luke D. Jones" <luke@ljones.dev>,
	"Denis Benato" <denis.benato@linux.dev>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,  Bartu Alev <bartualev@gmail.com>
Subject: [PATCH 3/3] platform/asus: asus-wmi: Document asus_wmi_evaluate_method_buf()
Date: Wed, 02 Dec 2026 02:31:44 +0300	[thread overview]
Message-ID: <20261202-asus-wmi-eval-buf-v1-3-640c12d437dc@gmail.com> (raw)
In-Reply-To: <20261202-asus-wmi-eval-buf-v1-0-640c12d437dc@gmail.com>

Add kernel-doc for the helper: its parameters, the fact that only
obj->buffer.length bytes are copied and the tail of ret_buffer is left
untouched on short replies, and the meaning of every error return, i.e.
-EIO when the evaluation fails, -ENODEV for the 0xfffffffe and 0xffffffff
sentinels, -ENOSPC when the reply does not fit and -ENODATA for any other
integer, a missing object or an unexpected type. The return values are
listed as a ReST list as Documentation/doc-guide/kernel-doc.rst asks.

Suggested-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Bartu Alev <bartualev@gmail.com>
---
 drivers/platform/asus/asus-wmi.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/asus/asus-wmi.c b/drivers/platform/asus/asus-wmi.c
index 015e207e840e6..4627ef0cad0c4 100644
--- a/drivers/platform/asus/asus-wmi.c
+++ b/drivers/platform/asus/asus-wmi.c
@@ -462,9 +462,32 @@ static int asus_wmi_evaluate_method5(u32 method_id,
 	return 0;
 }
 
-/*
- * Returns as an error if the method output is not a buffer. Typically this
- * means that the method called is unsupported.
+/**
+ * asus_wmi_evaluate_method_buf() - Evaluate a WMI method returning a buffer
+ * @method_id: WMI method ID to evaluate, such as ASUS_WMI_METHODID_DSTS
+ * @arg0: First method argument, usually the device ID
+ * @arg1: Second method argument
+ * @ret_buffer: Buffer to copy the reply into
+ * @size: Size of @ret_buffer
+ *
+ * Evaluate the method and copy the reply into @ret_buffer. The reply must
+ * be a non-empty ACPI buffer; only obj->buffer.length bytes are copied and
+ * the rest of @ret_buffer is left untouched, so callers that need the
+ * whole buffer must initialise it themselves. Anything other than a
+ * buffer is reported as an error. The firmware answers with an integer
+ * instead, %ASUS_WMI_UNSUPPORTED_METHOD (0xfffffffe) when it does not
+ * implement the device or method. That value and 0xffffffff, which
+ * asus_wmi_get_devstate() treats the same way, are reported as -ENODEV.
+ * No object at all, an empty buffer, an unexpected object type and any
+ * other integer, including the 0 some methods return when called without
+ * an argument, are reported as -ENODATA.
+ *
+ * Return:
+ * * %0		- reply copied into @ret_buffer
+ * * %-EIO	- the WMI evaluation failed
+ * * %-ENODEV	- the firmware does not implement the device or method
+ * * %-ENOSPC	- the reply does not fit into @ret_buffer
+ * * %-ENODATA	- no object, an empty buffer, an unexpected type or another integer
  */
 static int asus_wmi_evaluate_method_buf(u32 method_id,
 		u32 arg0, u32 arg1, u8 *ret_buffer, size_t size)

-- 
2.56.1


      parent reply	other threads:[~2026-12-01 23:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 23:31 [PATCH 0/3] platform/asus: asus-wmi: harden asus_wmi_evaluate_method_buf() Bartu Alev
2026-12-01 23:31 ` [PATCH 1/3] platform/asus: asus-wmi: Fix NULL deref and integer handling in asus_wmi_evaluate_method_buf() Bartu Alev
2026-12-01 23:31 ` [PATCH 2/3] platform/asus: asus-wmi: Use __free(kfree) " Bartu Alev
2026-12-01 23:31 ` Bartu Alev [this message]

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=20261202-asus-wmi-eval-buf-v1-3-640c12d437dc@gmail.com \
    --to=bartualev@gmail.com \
    --cc=corentin.chary@gmail.com \
    --cc=denis.benato@linux.dev \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luke@ljones.dev \
    --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®