Commit 95d42920 authored by Mark Pearson's avatar Mark Pearson Committed by Hans de Goede

platform/x86: think-lmi: Add pending_reboot support

The Think-lmi driver was missing pending_reboot support as it wasn't
available from the BIOS. Turns out this is really useful to have from
user space so implementing from a purely SW point of view.

Thanks to Mario Limonciello for guidance on how fwupd would use this.
Suggested-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarMark Pearson <markpearson@lenovo.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210628222846.8830-1-markpearson@lenovo.comSigned-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent e73f0f0e
...@@ -571,6 +571,11 @@ static ssize_t current_value_store(struct kobject *kobj, ...@@ -571,6 +571,11 @@ static ssize_t current_value_store(struct kobject *kobj,
else else
ret = tlmi_save_bios_settings(""); ret = tlmi_save_bios_settings("");
if (!ret && !tlmi_priv.pending_changes) {
tlmi_priv.pending_changes = true;
/* let userland know it may need to check reboot pending again */
kobject_uevent(&tlmi_priv.class_dev->kobj, KOBJ_CHANGE);
}
out: out:
kfree(auth_str); kfree(auth_str);
kfree(set_str); kfree(set_str);
...@@ -647,6 +652,14 @@ static struct kobj_type tlmi_pwd_setting_ktype = { ...@@ -647,6 +652,14 @@ static struct kobj_type tlmi_pwd_setting_ktype = {
.sysfs_ops = &tlmi_kobj_sysfs_ops, .sysfs_ops = &tlmi_kobj_sysfs_ops,
}; };
static ssize_t pending_reboot_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
return sprintf(buf, "%d\n", tlmi_priv.pending_changes);
}
static struct kobj_attribute pending_reboot = __ATTR_RO(pending_reboot);
/* ---- Initialisation --------------------------------------------------------- */ /* ---- Initialisation --------------------------------------------------------- */
static void tlmi_release_attr(void) static void tlmi_release_attr(void)
{ {
...@@ -667,6 +680,7 @@ static void tlmi_release_attr(void) ...@@ -667,6 +680,7 @@ static void tlmi_release_attr(void)
sysfs_remove_group(&tlmi_priv.pwd_power->kobj, &auth_attr_group); sysfs_remove_group(&tlmi_priv.pwd_power->kobj, &auth_attr_group);
kobject_put(&tlmi_priv.pwd_power->kobj); kobject_put(&tlmi_priv.pwd_power->kobj);
kset_unregister(tlmi_priv.authentication_kset); kset_unregister(tlmi_priv.authentication_kset);
sysfs_remove_file(&tlmi_priv.class_dev->kobj, &pending_reboot.attr);
} }
static int tlmi_sysfs_init(void) static int tlmi_sysfs_init(void)
...@@ -746,6 +760,11 @@ static int tlmi_sysfs_init(void) ...@@ -746,6 +760,11 @@ static int tlmi_sysfs_init(void)
if (ret) if (ret)
goto fail_create_attr; 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; return ret;
fail_create_attr: fail_create_attr:
......
...@@ -60,6 +60,7 @@ struct think_lmi { ...@@ -60,6 +60,7 @@ struct think_lmi {
bool can_get_bios_selections; bool can_get_bios_selections;
bool can_set_bios_password; bool can_set_bios_password;
bool can_get_password_settings; bool can_get_password_settings;
bool pending_changes;
struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT]; struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT];
struct device *class_dev; struct device *class_dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment