Skip to content

Commit

Permalink
platform/x86: think-lmi: Use WMI bus API when accessing BIOS settings
Browse files Browse the repository at this point in the history
Since the driver already binds to LENOVO_BIOS_SETTING_GUID, using
wmidev_block_query() inside tlmi_setting() allows for faster
access to BIOS settings.

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-4-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 82d3af6 commit 126a53a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 9 additions & 14 deletions drivers/platform/x86/think-lmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,20 +344,14 @@ static int tlmi_opcode_setting(char *setting, const char *value)
return ret;
}

static int tlmi_setting(int item, char **value, const char *guid_string)
static int tlmi_setting(struct wmi_device *wdev, int item, char **value)
{
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))
return -EIO;

obj = output.pointer;
obj = wmidev_block_query(wdev, item);
if (!obj)
return -ENODATA;
return -EIO;

ret = tlmi_extract_output_string(obj, value);
kfree(obj);
Expand Down Expand Up @@ -995,7 +989,7 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a
char *item, *value;
int ret;

ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID);
ret = tlmi_setting(setting->wdev, setting->index, &item);
if (ret)
return ret;

Expand Down Expand Up @@ -1588,7 +1582,7 @@ static struct tlmi_pwd_setting *tlmi_create_auth(const char *pwd_type,
return new_pwd;
}

static int tlmi_analyze(void)
static int tlmi_analyze(struct wmi_device *wdev)
{
int i, ret;

Expand Down Expand Up @@ -1625,7 +1619,7 @@ static int tlmi_analyze(void)
char *item = NULL;

tlmi_priv.setting[i] = NULL;
ret = tlmi_setting(i, &item, LENOVO_BIOS_SETTING_GUID);
ret = tlmi_setting(wdev, i, &item);
if (ret)
break;
if (!item)
Expand All @@ -1648,6 +1642,7 @@ static int tlmi_analyze(void)
kfree(item);
goto fail_clear_attr;
}
setting->wdev = wdev;
setting->index = i;
strscpy(setting->display_name, item);
/* If BIOS selections supported, load those */
Expand All @@ -1666,7 +1661,7 @@ static int tlmi_analyze(void)
*/
char *optitem, *optstart, *optend;

if (!tlmi_setting(setting->index, &optitem, LENOVO_BIOS_SETTING_GUID)) {
if (!tlmi_setting(setting->wdev, setting->index, &optitem)) {
optstart = strstr(optitem, "[Optional:");
if (optstart) {
optstart += strlen("[Optional:");
Expand Down Expand Up @@ -1791,7 +1786,7 @@ static int tlmi_probe(struct wmi_device *wdev, const void *context)
{
int ret;

ret = tlmi_analyze();
ret = tlmi_analyze(wdev);
if (ret)
return ret;

Expand Down
2 changes: 2 additions & 0 deletions drivers/platform/x86/think-lmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define _THINK_LMI_H_

#include <linux/types.h>
#include <linux/wmi.h>

#define TLMI_SETTINGS_COUNT 256
#define TLMI_SETTINGS_MAXLEN 512
Expand Down Expand Up @@ -87,6 +88,7 @@ struct tlmi_pwd_setting {
/* Attribute setting details */
struct tlmi_attr_setting {
struct kobject kobj;
struct wmi_device *wdev;
int index;
char display_name[TLMI_SETTINGS_MAXLEN];
char *possible_values;
Expand Down

0 comments on commit 126a53a

Please sign in to comment.