Skip to content

Commit cf337f2

Browse files
mrhpearsonjwrdegoede
authored andcommitted
platform/x86: think-lmi: only display possible_values if available
Some attributes don't have any values available. In those cases don't make the possible_values entry visible. 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: Thomas Weißschuh <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 45e2128 commit cf337f2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,9 +941,6 @@ static ssize_t possible_values_show(struct kobject *kobj, struct kobj_attribute
941941
{
942942
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
943943

944-
if (!tlmi_priv.can_get_bios_selections)
945-
return -EOPNOTSUPP;
946-
947944
return sysfs_emit(buf, "%s\n", setting->possible_values);
948945
}
949946

@@ -1052,6 +1049,18 @@ static struct kobj_attribute attr_current_val = __ATTR_RW_MODE(current_value, 06
10521049

10531050
static struct kobj_attribute attr_type = __ATTR_RO(type);
10541051

1052+
static umode_t attr_is_visible(struct kobject *kobj,
1053+
struct attribute *attr, int n)
1054+
{
1055+
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
1056+
1057+
/* We don't want to display possible_values attributes if not available */
1058+
if ((attr == &attr_possible_values.attr) && (!setting->possible_values))
1059+
return 0;
1060+
1061+
return attr->mode;
1062+
}
1063+
10551064
static struct attribute *tlmi_attrs[] = {
10561065
&attr_displ_name.attr,
10571066
&attr_current_val.attr,
@@ -1061,6 +1070,7 @@ static struct attribute *tlmi_attrs[] = {
10611070
};
10621071

10631072
static const struct attribute_group tlmi_attr_group = {
1073+
.is_visible = attr_is_visible,
10641074
.attrs = tlmi_attrs,
10651075
};
10661076

0 commit comments

Comments
 (0)