Skip to content

Commit

Permalink
platform/x86: think-lmi: Move pending_reboot_attr to the attributes s…
Browse files Browse the repository at this point in the history
…ysfs dir

Move the pending_reboot node under attributes dir where it should live, as
documented in: Documentation/ABI/testing/sysfs-class-firmware-attributes.

Also move the create / remove code to be together with the other code
populating / cleaning the attributes sysfs dir. In the removal path this
is necessary so that the remove is done before the
kset_unregister(tlmi_priv.attribute_kset) call.

Signed-off-by: Mark Pearson <markpearson@lenovo.com>
Co-developed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210717143607.3580-1-hdegoede@redhat.com
  • Loading branch information
Mark Pearson authored and Hans de Goede committed Jul 17, 2021
1 parent 7f5231b commit e62fb1e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/platform/x86/think-lmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ static void tlmi_release_attr(void)
kobject_put(&tlmi_priv.setting[i]->kobj);
}
}
sysfs_remove_file(&tlmi_priv.attribute_kset->kobj, &pending_reboot.attr);
kset_unregister(tlmi_priv.attribute_kset);

/* Authentication structures */
Expand All @@ -680,7 +681,6 @@ static void tlmi_release_attr(void)
sysfs_remove_group(&tlmi_priv.pwd_power->kobj, &auth_attr_group);
kobject_put(&tlmi_priv.pwd_power->kobj);
kset_unregister(tlmi_priv.authentication_kset);
sysfs_remove_file(&tlmi_priv.class_dev->kobj, &pending_reboot.attr);
}

static int tlmi_sysfs_init(void)
Expand Down Expand Up @@ -733,6 +733,10 @@ static int tlmi_sysfs_init(void)
goto fail_create_attr;
}

ret = sysfs_create_file(&tlmi_priv.attribute_kset->kobj, &pending_reboot.attr);
if (ret)
goto fail_create_attr;

/* Create authentication entries */
tlmi_priv.authentication_kset = kset_create_and_add("authentication", NULL,
&tlmi_priv.class_dev->kobj);
Expand Down Expand Up @@ -760,11 +764,6 @@ static int tlmi_sysfs_init(void)
if (ret)
goto fail_create_attr;

/* Create global sysfs files */
ret = sysfs_create_file(&tlmi_priv.class_dev->kobj, &pending_reboot.attr);
if (ret)
goto fail_create_attr;

return ret;

fail_create_attr:
Expand Down

0 comments on commit e62fb1e

Please sign in to comment.