Skip to content

Commit 126a53a

Browse files
Wer-Wolfij-intel
authored andcommitted
platform/x86: think-lmi: Use WMI bus API when accessing BIOS settings
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 <[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 82d3af6 commit 126a53a

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -344,20 +344,14 @@ static int tlmi_opcode_setting(char *setting, const char *value)
344344
return ret;
345345
}
346346

347-
static int tlmi_setting(int item, char **value, const char *guid_string)
347+
static int tlmi_setting(struct wmi_device *wdev, int item, char **value)
348348
{
349-
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
350349
union acpi_object *obj;
351-
acpi_status status;
352350
int ret;
353351

354-
status = wmi_query_block(guid_string, item, &output);
355-
if (ACPI_FAILURE(status))
356-
return -EIO;
357-
358-
obj = output.pointer;
352+
obj = wmidev_block_query(wdev, item);
359353
if (!obj)
360-
return -ENODATA;
354+
return -EIO;
361355

362356
ret = tlmi_extract_output_string(obj, value);
363357
kfree(obj);
@@ -995,7 +989,7 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a
995989
char *item, *value;
996990
int ret;
997991

998-
ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID);
992+
ret = tlmi_setting(setting->wdev, setting->index, &item);
999993
if (ret)
1000994
return ret;
1001995

@@ -1588,7 +1582,7 @@ static struct tlmi_pwd_setting *tlmi_create_auth(const char *pwd_type,
15881582
return new_pwd;
15891583
}
15901584

1591-
static int tlmi_analyze(void)
1585+
static int tlmi_analyze(struct wmi_device *wdev)
15921586
{
15931587
int i, ret;
15941588

@@ -1625,7 +1619,7 @@ static int tlmi_analyze(void)
16251619
char *item = NULL;
16261620

16271621
tlmi_priv.setting[i] = NULL;
1628-
ret = tlmi_setting(i, &item, LENOVO_BIOS_SETTING_GUID);
1622+
ret = tlmi_setting(wdev, i, &item);
16291623
if (ret)
16301624
break;
16311625
if (!item)
@@ -1648,6 +1642,7 @@ static int tlmi_analyze(void)
16481642
kfree(item);
16491643
goto fail_clear_attr;
16501644
}
1645+
setting->wdev = wdev;
16511646
setting->index = i;
16521647
strscpy(setting->display_name, item);
16531648
/* If BIOS selections supported, load those */
@@ -1666,7 +1661,7 @@ static int tlmi_analyze(void)
16661661
*/
16671662
char *optitem, *optstart, *optend;
16681663

1669-
if (!tlmi_setting(setting->index, &optitem, LENOVO_BIOS_SETTING_GUID)) {
1664+
if (!tlmi_setting(setting->wdev, setting->index, &optitem)) {
16701665
optstart = strstr(optitem, "[Optional:");
16711666
if (optstart) {
16721667
optstart += strlen("[Optional:");
@@ -1791,7 +1786,7 @@ static int tlmi_probe(struct wmi_device *wdev, const void *context)
17911786
{
17921787
int ret;
17931788

1794-
ret = tlmi_analyze();
1789+
ret = tlmi_analyze(wdev);
17951790
if (ret)
17961791
return ret;
17971792

drivers/platform/x86/think-lmi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#define _THINK_LMI_H_
55

66
#include <linux/types.h>
7+
#include <linux/wmi.h>
78

89
#define TLMI_SETTINGS_COUNT 256
910
#define TLMI_SETTINGS_MAXLEN 512
@@ -87,6 +88,7 @@ struct tlmi_pwd_setting {
8788
/* Attribute setting details */
8889
struct tlmi_attr_setting {
8990
struct kobject kobj;
91+
struct wmi_device *wdev;
9092
int index;
9193
char display_name[TLMI_SETTINGS_MAXLEN];
9294
char *possible_values;

0 commit comments

Comments
 (0)