s390/qeth: simplify L3 sysfs group management
authorJulian Wiedmann <jwi@linux.vnet.ibm.com>
Mon, 18 Sep 2017 19:18:19 +0000 (21:18 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 Sep 2017 21:41:37 +0000 (14:41 -0700)
Use the right helpers to create/remove all attribute groups in one go.

Suggested-by: Hans Wippel <hwippel@linux.vnet.ibm.com>
Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Reviewed-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_l3_sys.c

index e8bcc314cc5f9d21683170c23dd0b3880f3ee6cb..0ad0f7f4b23f0f083c13cfcc69058b3b0030bf39 100644 (file)
@@ -1028,52 +1028,31 @@ static const struct attribute_group qeth_device_rxip_group = {
        .attrs = qeth_rxip_device_attrs,
 };
 
+static const struct attribute_group *qeth_l3_only_attr_groups[] = {
+       &qeth_l3_device_attr_group,
+       &qeth_device_ipato_group,
+       &qeth_device_vipa_group,
+       &qeth_device_rxip_group,
+       NULL,
+};
+
 int qeth_l3_create_device_attributes(struct device *dev)
 {
-       int ret;
-
-       ret = sysfs_create_group(&dev->kobj, &qeth_l3_device_attr_group);
-       if (ret)
-               return ret;
-
-       ret = sysfs_create_group(&dev->kobj, &qeth_device_ipato_group);
-       if (ret) {
-               sysfs_remove_group(&dev->kobj, &qeth_l3_device_attr_group);
-               return ret;
-       }
-
-       ret = sysfs_create_group(&dev->kobj, &qeth_device_vipa_group);
-       if (ret) {
-               sysfs_remove_group(&dev->kobj, &qeth_l3_device_attr_group);
-               sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group);
-               return ret;
-       }
-
-       ret = sysfs_create_group(&dev->kobj, &qeth_device_rxip_group);
-       if (ret) {
-               sysfs_remove_group(&dev->kobj, &qeth_l3_device_attr_group);
-               sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group);
-               sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group);
-               return ret;
-       }
-       return 0;
+       return sysfs_create_groups(&dev->kobj, qeth_l3_only_attr_groups);
 }
 
 void qeth_l3_remove_device_attributes(struct device *dev)
 {
-       sysfs_remove_group(&dev->kobj, &qeth_l3_device_attr_group);
-       sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group);
-       sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group);
-       sysfs_remove_group(&dev->kobj, &qeth_device_rxip_group);
+       sysfs_remove_groups(&dev->kobj, qeth_l3_only_attr_groups);
 }
 
 const struct attribute_group *qeth_l3_attr_groups[] = {
        &qeth_device_attr_group,
        &qeth_device_blkt_group,
-       /* l3 specific, see l3_{create,remove}_device_attributes(): */
+       /* l3 specific, see qeth_l3_only_attr_groups: */
        &qeth_l3_device_attr_group,
        &qeth_device_ipato_group,
        &qeth_device_vipa_group,
        &qeth_device_rxip_group,
-NULL,
+       NULL,
 };