Skip to content

Commit

Permalink
platform/x86: think-lmi: Use ACPI object when extracting strings
Browse files Browse the repository at this point in the history
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>
Link: https://lore.kernel.org/r/20250216193251.866125-3-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>
  • Loading branch information
Armin Wolf authored and Ilpo Järvinen committed Feb 24, 2025
1 parent 27cc291 commit 82d3af6
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions drivers/platform/x86/think-lmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -352,37 +347,44 @@ 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;
}

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;
}

Expand Down

0 comments on commit 82d3af6

Please sign in to comment.