Unverified Commit 8508427a authored by Mark Pearson's avatar Mark Pearson Committed by Ilpo Järvinen
Browse files

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: a40cd7ef ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Signed-off-by: default avatarMark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20250520005027.3840705-1-mpearson-lenovo@squebb.ca


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 29e4e6b4
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -1061,7 +1061,7 @@ static ssize_t current_value_store(struct kobject *kobj,
			ret = -EINVAL;
			goto out;
		}
		set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->display_name,
		set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->name,
				    new_setting, tlmi_priv.pwd_admin->signature);
		if (!set_str) {
			ret = -ENOMEM;
@@ -1092,7 +1092,7 @@ static ssize_t current_value_store(struct kobject *kobj,
				goto out;
		}

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

		if (auth_str)
			set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->display_name,
			set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->name,
					    new_setting, auth_str);
		else
			set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
			set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->name,
					    new_setting);
		if (!set_str) {
			ret = -ENOMEM;
@@ -1629,9 +1629,6 @@ static int tlmi_analyze(struct wmi_device *wdev)
			continue;
		}

		/* It is not allowed to have '/' for file name. Convert it into '\'. */
		strreplace(item, '/', '\\');

		/* Remove the value part */
		strreplace(item, ',', '\0');

@@ -1644,10 +1641,15 @@ static int tlmi_analyze(struct wmi_device *wdev)
		}
		setting->wdev = wdev;
		setting->index = i;

		strscpy(setting->name, item);
		/* It is not allowed to have '/' for file name. Convert it into '\'. */
		strreplace(item, '/', '\\');
		strscpy(setting->display_name, item);

		/* If BIOS selections supported, load those */
		if (tlmi_priv.can_get_bios_selections) {
			ret = tlmi_get_bios_selections(setting->display_name,
			ret = tlmi_get_bios_selections(setting->name,
						       &setting->possible_values);
			if (ret || !setting->possible_values)
				pr_info("Error retrieving possible values for %d : %s\n",
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ struct tlmi_attr_setting {
	struct kobject kobj;
	struct wmi_device *wdev;
	int index;
	char name[TLMI_SETTINGS_MAXLEN];
	char display_name[TLMI_SETTINGS_MAXLEN];
	char *possible_values;
};