s390/stp: let subsys_system_register() sysfs attributes
authorJulian Wiedmann <jwi@linux.ibm.com>
Wed, 11 Nov 2020 07:13:14 +0000 (08:13 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Fri, 20 Nov 2020 18:19:11 +0000 (19:19 +0100)
Instead of creating the sysfs attributes for the stp root_dev by hand,
pass them to subsys_system_register() as parameter.

This also ensures that the attributes are available when the KOBJ_ADD
event is raised.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/kernel/time.c

index 0ac30ee2c6330248447f899f4debafef99f49c62..c59cb44fbb7d7424800f4910ca0584675ed38b44 100644 (file)
@@ -927,41 +927,25 @@ static ssize_t online_store(struct device *dev,
  */
 static DEVICE_ATTR_RW(online);
 
-static struct device_attribute *stp_attributes[] = {
-       &dev_attr_ctn_id,
-       &dev_attr_ctn_type,
-       &dev_attr_dst_offset,
-       &dev_attr_leap_seconds,
-       &dev_attr_online,
-       &dev_attr_leap_seconds_scheduled,
-       &dev_attr_stratum,
-       &dev_attr_time_offset,
-       &dev_attr_time_zone_offset,
-       &dev_attr_timing_mode,
-       &dev_attr_timing_state,
+static struct attribute *stp_dev_attrs[] = {
+       &dev_attr_ctn_id.attr,
+       &dev_attr_ctn_type.attr,
+       &dev_attr_dst_offset.attr,
+       &dev_attr_leap_seconds.attr,
+       &dev_attr_online.attr,
+       &dev_attr_leap_seconds_scheduled.attr,
+       &dev_attr_stratum.attr,
+       &dev_attr_time_offset.attr,
+       &dev_attr_time_zone_offset.attr,
+       &dev_attr_timing_mode.attr,
+       &dev_attr_timing_state.attr,
        NULL
 };
+ATTRIBUTE_GROUPS(stp_dev);
 
 static int __init stp_init_sysfs(void)
 {
-       struct device_attribute **attr;
-       int rc;
-
-       rc = subsys_system_register(&stp_subsys, NULL);
-       if (rc)
-               goto out;
-       for (attr = stp_attributes; *attr; attr++) {
-               rc = device_create_file(stp_subsys.dev_root, *attr);
-               if (rc)
-                       goto out_unreg;
-       }
-       return 0;
-out_unreg:
-       for (; attr >= stp_attributes; attr--)
-               device_remove_file(stp_subsys.dev_root, *attr);
-       bus_unregister(&stp_subsys);
-out:
-       return rc;
+       return subsys_system_register(&stp_subsys, stp_dev_groups);
 }
 
 device_initcall(stp_init_sysfs);