Skip to content

Commit 82d3af6

Browse files
Wer-Wolfij-intel
authored andcommitted
platform/x86: think-lmi: Use ACPI object when extracting strings
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 <[email protected]> Signed-off-by: Armin Wolf <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 27cc291 commit 82d3af6

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,11 @@ static int tlmi_simple_call(const char *guid, const char *arg)
262262
return 0;
263263
}
264264

265-
/* Extract output string from WMI return buffer */
266-
static int tlmi_extract_output_string(const struct acpi_buffer *output,
267-
char **string)
265+
/* Extract output string from WMI return value */
266+
static int tlmi_extract_output_string(union acpi_object *obj, char **string)
268267
{
269-
const union acpi_object *obj;
270268
char *s;
271269

272-
obj = output->pointer;
273-
if (!obj)
274-
return -ENOMEM;
275270
if (obj->type != ACPI_TYPE_STRING || !obj->string.pointer)
276271
return -EIO;
277272

@@ -352,37 +347,44 @@ static int tlmi_opcode_setting(char *setting, const char *value)
352347
static int tlmi_setting(int item, char **value, const char *guid_string)
353348
{
354349
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
350+
union acpi_object *obj;
355351
acpi_status status;
356352
int ret;
357353

358354
status = wmi_query_block(guid_string, item, &output);
359-
if (ACPI_FAILURE(status)) {
360-
kfree(output.pointer);
355+
if (ACPI_FAILURE(status))
361356
return -EIO;
362-
}
363357

364-
ret = tlmi_extract_output_string(&output, value);
365-
kfree(output.pointer);
358+
obj = output.pointer;
359+
if (!obj)
360+
return -ENODATA;
361+
362+
ret = tlmi_extract_output_string(obj, value);
363+
kfree(obj);
364+
366365
return ret;
367366
}
368367

369368
static int tlmi_get_bios_selections(const char *item, char **value)
370369
{
371370
const struct acpi_buffer input = { strlen(item), (char *)item };
372371
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
372+
union acpi_object *obj;
373373
acpi_status status;
374374
int ret;
375375

376376
status = wmi_evaluate_method(LENOVO_GET_BIOS_SELECTIONS_GUID,
377377
0, 0, &input, &output);
378-
379-
if (ACPI_FAILURE(status)) {
380-
kfree(output.pointer);
378+
if (ACPI_FAILURE(status))
381379
return -EIO;
382-
}
383380

384-
ret = tlmi_extract_output_string(&output, value);
385-
kfree(output.pointer);
381+
obj = output.pointer;
382+
if (!obj)
383+
return -ENODATA;
384+
385+
ret = tlmi_extract_output_string(obj, value);
386+
kfree(obj);
387+
386388
return ret;
387389
}
388390

0 commit comments

Comments
 (0)