Skip to content

Commit 0fdf10e

Browse files
superm1jwrdegoede
authored andcommitted
platform/x86: think-lmi: Split current_value to reflect only the value
Currently attributes will show things like: `BootOrderLock,Disable` rather than just `Disable`. Of course this works, but the attribute is intended to be read by userspace tools and not require further processing. That is a userspace tool can display a drop down of `possible_values` and `current_value` is one of them from the list. This also aligns `think-lmi` with how `dell-wmi-sysman` works. Signed-off-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 1bcad8e commit 0fdf10e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,19 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *at
492492
static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
493493
{
494494
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
495-
char *item;
495+
char *item, *value;
496496
int ret;
497497

498498
ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID);
499499
if (ret)
500500
return ret;
501501

502-
ret = sysfs_emit(buf, "%s\n", item);
502+
/* validate and split from `item,value` -> `value` */
503+
value = strpbrk(item, ",");
504+
if (!value || value == item || !strlen(value + 1))
505+
return -EINVAL;
506+
507+
ret = sysfs_emit(buf, "%s\n", value + 1);
503508
kfree(item);
504509
return ret;
505510
}

0 commit comments

Comments
 (0)