Skip to content

Commit 8508427

Browse files
mrhpearsonij-intel
authored andcommitted
platform/x86: think-lmi: Fix attribute name usage for non-compliant items
A few, quite rare, WMI attributes have names that are not compatible with filenames, e.g. "Intel VT for Directed I/O (VT-d)". For these cases the '/' gets replaced with '\' for display, but doesn't get switched again when doing the WMI access. Fix this by keeping the original attribute name and using that for sending commands to the BIOS Fixes: a40cd7e ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms") Signed-off-by: Mark Pearson <[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 29e4e6b commit 8508427

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,8 +1061,8 @@ static ssize_t current_value_store(struct kobject *kobj,
10611061
ret = -EINVAL;
10621062
goto out;
10631063
}
1064-
set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->display_name,
1065-
new_setting, tlmi_priv.pwd_admin->signature);
1064+
set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->name,
1065+
new_setting, tlmi_priv.pwd_admin->signature);
10661066
if (!set_str) {
10671067
ret = -ENOMEM;
10681068
goto out;
@@ -1092,7 +1092,7 @@ static ssize_t current_value_store(struct kobject *kobj,
10921092
goto out;
10931093
}
10941094

1095-
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
1095+
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->name,
10961096
new_setting);
10971097
if (!set_str) {
10981098
ret = -ENOMEM;
@@ -1120,11 +1120,11 @@ static ssize_t current_value_store(struct kobject *kobj,
11201120
}
11211121

11221122
if (auth_str)
1123-
set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->display_name,
1124-
new_setting, auth_str);
1123+
set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->name,
1124+
new_setting, auth_str);
11251125
else
1126-
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
1127-
new_setting);
1126+
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->name,
1127+
new_setting);
11281128
if (!set_str) {
11291129
ret = -ENOMEM;
11301130
goto out;
@@ -1629,9 +1629,6 @@ static int tlmi_analyze(struct wmi_device *wdev)
16291629
continue;
16301630
}
16311631

1632-
/* It is not allowed to have '/' for file name. Convert it into '\'. */
1633-
strreplace(item, '/', '\\');
1634-
16351632
/* Remove the value part */
16361633
strreplace(item, ',', '\0');
16371634

@@ -1644,11 +1641,16 @@ static int tlmi_analyze(struct wmi_device *wdev)
16441641
}
16451642
setting->wdev = wdev;
16461643
setting->index = i;
1644+
1645+
strscpy(setting->name, item);
1646+
/* It is not allowed to have '/' for file name. Convert it into '\'. */
1647+
strreplace(item, '/', '\\');
16471648
strscpy(setting->display_name, item);
1649+
16481650
/* If BIOS selections supported, load those */
16491651
if (tlmi_priv.can_get_bios_selections) {
1650-
ret = tlmi_get_bios_selections(setting->display_name,
1651-
&setting->possible_values);
1652+
ret = tlmi_get_bios_selections(setting->name,
1653+
&setting->possible_values);
16521654
if (ret || !setting->possible_values)
16531655
pr_info("Error retrieving possible values for %d : %s\n",
16541656
i, setting->display_name);

drivers/platform/x86/think-lmi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct tlmi_attr_setting {
9090
struct kobject kobj;
9191
struct wmi_device *wdev;
9292
int index;
93+
char name[TLMI_SETTINGS_MAXLEN];
9394
char display_name[TLMI_SETTINGS_MAXLEN];
9495
char *possible_values;
9596
};

0 commit comments

Comments
 (0)