]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
platform/x86: think-lmi: Move pending_reboot_attr to the attributes sysfs dir
authorMark Pearson <markpearson@lenovo.com>
Sat, 17 Jul 2021 14:36:05 +0000 (16:36 +0200)
committerHans de Goede <hdegoede@redhat.com>
Sat, 17 Jul 2021 14:39:55 +0000 (16:39 +0200)
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
drivers/platform/x86/think-lmi.c

index 64dcec53a7a05e494a2f4c55eff1609191d14bcb..989a8221dcd81b9b952a787d860a22019d4ed762 100644 (file)
@@ -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 */
@@ -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)
@@ -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);
@@ -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: