Skip to content

Commit

Permalink
platform/x86: think-lmi: Clean up display of current_value on Thinkst…
Browse files Browse the repository at this point in the history
…ation

[ Upstream commit 7065655 ]

On ThinkStations on retrieving the attribute value the BIOS appends the
possible values to the string.
Clean up the display in the current_value_show function so the options
part is not displayed.

Fixes: a40cd7e ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Reported by Mario Limoncello <Mario.Limonciello@amd.com>
Link: fwupd/fwupd#5077 (comment)
Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20230403013120.2105-2-mpearson-lenovo@squebb.ca
Tested-by: Mario Limonciello <mario.limonciello@amd.com>
Tested-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
mrhpearson authored and Sasha Levin committed Apr 12, 2023
1 parent b953a45 commit 60f1e8b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/platform/x86/think-lmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *at
static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
char *item, *value;
char *item, *value, *p;
int ret;

ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID);
Expand All @@ -515,9 +515,12 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a
value = strpbrk(item, ",");
if (!value || value == item || !strlen(value + 1))
ret = -EINVAL;
else
else {
/* On Workstations remove the Options part after the value */
p = strchrnul(value, ';');
*p = '\0';
ret = sysfs_emit(buf, "%s\n", value + 1);

}
kfree(item);

return ret;
Expand Down

0 comments on commit 60f1e8b

Please sign in to comment.