]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
platform/x86: think-lmi: Clean up display of current_value on Thinkstation
authorMark Pearson <mpearson-lenovo@squebb.ca>
Mon, 3 Apr 2023 01:31:20 +0000 (21:31 -0400)
committerHans de Goede <hdegoede@redhat.com>
Mon, 3 Apr 2023 09:36:44 +0000 (11:36 +0200)
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: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Reported by Mario Limoncello <Mario.Limonciello@amd.com>
Link: https://github.com/fwupd/fwupd/issues/5077#issuecomment-1488730526
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>
drivers/platform/x86/think-lmi.c

index 87f832142d8d6d440f95caeb44e494d184074dd2..78dc82bda4ddeac371580b48aacbcc5a3ad6e5be 100644 (file)
@@ -920,7 +920,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);
@@ -931,9 +931,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;