From: Armin Wolf <W_Armin@gmx.de>
To: james@equiv.tech, markpearson@lenovo.com, jorge.lopez2@hp.com
Cc: jdelvare@suse.com, linux@roeck-us.net,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org, corbet@lwn.net,
linux-doc@vger.kernel.org
Subject: [PATCH v2 2/8] platform/x86: think-lmi: Use ACPI object when extracting strings
Date: Sun, 16 Feb 2025 20:32:45 +0100 [thread overview]
Message-ID: <20250216193251.866125-3-W_Armin@gmx.de> (raw)
In-Reply-To: <20250216193251.866125-1-W_Armin@gmx.de>
Move the ACPI buffer handling out of tlmi_extract_output_string()
and instead pass the unpacked ACPI object to prepare for future
changes.
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/platform/x86/think-lmi.c | 38 +++++++++++++++++---------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
index 323316ac6783..2c94a4af9a1d 100644
--- a/drivers/platform/x86/think-lmi.c
+++ b/drivers/platform/x86/think-lmi.c
@@ -262,16 +262,11 @@ static int tlmi_simple_call(const char *guid, const char *arg)
return 0;
}
-/* Extract output string from WMI return buffer */
-static int tlmi_extract_output_string(const struct acpi_buffer *output,
- char **string)
+/* Extract output string from WMI return value */
+static int tlmi_extract_output_string(union acpi_object *obj, char **string)
{
- const union acpi_object *obj;
char *s;
- obj = output->pointer;
- if (!obj)
- return -ENOMEM;
if (obj->type != ACPI_TYPE_STRING || !obj->string.pointer)
return -EIO;
@@ -352,17 +347,21 @@ static int tlmi_opcode_setting(char *setting, const char *value)
static int tlmi_setting(int item, char **value, const char *guid_string)
{
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+ union acpi_object *obj;
acpi_status status;
int ret;
status = wmi_query_block(guid_string, item, &output);
- if (ACPI_FAILURE(status)) {
- kfree(output.pointer);
+ if (ACPI_FAILURE(status))
return -EIO;
- }
- ret = tlmi_extract_output_string(&output, value);
- kfree(output.pointer);
+ obj = output.pointer;
+ if (!obj)
+ return -ENODATA;
+
+ ret = tlmi_extract_output_string(obj, value);
+ kfree(obj);
+
return ret;
}
@@ -370,19 +369,22 @@ static int tlmi_get_bios_selections(const char *item, char **value)
{
const struct acpi_buffer input = { strlen(item), (char *)item };
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+ union acpi_object *obj;
acpi_status status;
int ret;
status = wmi_evaluate_method(LENOVO_GET_BIOS_SELECTIONS_GUID,
0, 0, &input, &output);
-
- if (ACPI_FAILURE(status)) {
- kfree(output.pointer);
+ if (ACPI_FAILURE(status))
return -EIO;
- }
- ret = tlmi_extract_output_string(&output, value);
- kfree(output.pointer);
+ obj = output.pointer;
+ if (!obj)
+ return -ENODATA;
+
+ ret = tlmi_extract_output_string(obj, value);
+ kfree(obj);
+
return ret;
}
--
2.39.5
next prev parent reply other threads:[~2025-02-16 19:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-16 19:32 [PATCH v2 0/8] platform/x86: wmi: Rework WMI device enabling Armin Wolf
2025-02-16 19:32 ` [PATCH v2 1/8] hwmon: (hp-wmi-sensors) Use the WMI bus API when accessing sensors Armin Wolf
2025-02-16 19:32 ` Armin Wolf [this message]
2025-02-16 19:32 ` [PATCH v2 3/8] platform/x86: think-lmi: Use WMI bus API when accessing BIOS settings Armin Wolf
2025-02-16 19:32 ` [PATCH v2 4/8] platform/x86: hp-bioscfg: Use wmi_instance_count() Armin Wolf
2025-02-16 19:32 ` [PATCH v2 5/8] platform/x86: wmi: Use devres to disable the WMI device Armin Wolf
2025-02-16 19:32 ` [PATCH v2 6/8] platform/x86: wmi: Rework WCxx/WExx ACPI method handling Armin Wolf
2025-02-16 19:32 ` [PATCH v2 7/8] platform/x86: wmi: Call WCxx methods when setting data blocks Armin Wolf
2025-02-16 19:32 ` [PATCH v2 8/8] platform/x86: wmi: Update documentation regarding the GUID-based API Armin Wolf
2025-02-24 15:17 ` [PATCH v2 0/8] platform/x86: wmi: Rework WMI device enabling Ilpo Järvinen
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=20250216193251.866125-3-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=corbet@lwn.net \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=james@equiv.tech \
--cc=jdelvare@suse.com \
--cc=jorge.lopez2@hp.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=markpearson@lenovo.com \
--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®