Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Armin Wolf and committed by
Ilpo Järvinen
82d3af6b 27cc2914

+20 -18
+20 -18
drivers/platform/x86/think-lmi.c
··· 262 262 return 0; 263 263 } 264 264 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) 268 267 { 269 - const union acpi_object *obj; 270 268 char *s; 271 269 272 - obj = output->pointer; 273 - if (!obj) 274 - return -ENOMEM; 275 270 if (obj->type != ACPI_TYPE_STRING || !obj->string.pointer) 276 271 return -EIO; 277 272 ··· 347 352 static int tlmi_setting(int item, char **value, const char *guid_string) 348 353 { 349 354 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 355 + union acpi_object *obj; 350 356 acpi_status status; 351 357 int ret; 352 358 353 359 status = wmi_query_block(guid_string, item, &output); 354 - if (ACPI_FAILURE(status)) { 355 - kfree(output.pointer); 360 + if (ACPI_FAILURE(status)) 356 361 return -EIO; 357 - } 358 362 359 - ret = tlmi_extract_output_string(&output, value); 360 - kfree(output.pointer); 363 + obj = output.pointer; 364 + if (!obj) 365 + return -ENODATA; 366 + 367 + ret = tlmi_extract_output_string(obj, value); 368 + kfree(obj); 369 + 361 370 return ret; 362 371 } 363 372 ··· 369 370 { 370 371 const struct acpi_buffer input = { strlen(item), (char *)item }; 371 372 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 373 + union acpi_object *obj; 372 374 acpi_status status; 373 375 int ret; 374 376 375 377 status = wmi_evaluate_method(LENOVO_GET_BIOS_SELECTIONS_GUID, 376 378 0, 0, &input, &output); 377 - 378 - if (ACPI_FAILURE(status)) { 379 - kfree(output.pointer); 379 + if (ACPI_FAILURE(status)) 380 380 return -EIO; 381 - } 382 381 383 - ret = tlmi_extract_output_string(&output, value); 384 - kfree(output.pointer); 382 + obj = output.pointer; 383 + if (!obj) 384 + return -ENODATA; 385 + 386 + ret = tlmi_extract_output_string(obj, value); 387 + kfree(obj); 388 + 385 389 return ret; 386 390 } 387 391