lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 31 Aug 2020 11:58:09 -0500
From:   Thomas Falcon <tlfalcon@...ux.ibm.com>
To:     netdev@...r.kernel.org
Cc:     drt@...ux.vnet.ibm.com, sukadev@...ux.vnet.ibm.com,
        ljp@...ux.vnet.ibm.com, cforno12@...ux.ibm.com,
        Thomas Falcon <tlfalcon@...ux.ibm.com>
Subject: [PATCH net-next 1/5] ibmvnic: Create failover sysfs as part of an attribute group

Create a sysfs attribute group and make failover sysfs file a
member.

Signed-off-by: Thomas Falcon <tlfalcon@...ux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 86a83e5..91b9cc3 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -5047,7 +5047,7 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter, bool reset)
 	return rc;
 }
 
-static struct device_attribute dev_attr_failover;
+static const struct attribute_group *dev_attr_groups[];
 
 static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
 {
@@ -5126,9 +5126,9 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
 	netdev->min_mtu = adapter->min_mtu - ETH_HLEN;
 	netdev->max_mtu = adapter->max_mtu - ETH_HLEN;
 
-	rc = device_create_file(&dev->dev, &dev_attr_failover);
+	rc = sysfs_create_groups(&dev->dev.kobj, dev_attr_groups);
 	if (rc)
-		goto ibmvnic_dev_file_err;
+		goto ibmvnic_dev_groups_err;
 
 	netif_carrier_off(netdev);
 	rc = register_netdev(netdev);
@@ -5145,14 +5145,11 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
 	return 0;
 
 ibmvnic_register_fail:
-	device_remove_file(&dev->dev, &dev_attr_failover);
-
-ibmvnic_dev_file_err:
+	sysfs_remove_groups(&dev->dev.kobj, dev_attr_groups);
+ibmvnic_dev_groups_err:
 	release_stats_token(adapter);
-
 ibmvnic_stats_fail:
 	release_stats_buffers(adapter);
-
 ibmvnic_init_fail:
 	release_sub_crqs(adapter, 1);
 	release_crq_queue(adapter);
@@ -5194,13 +5191,15 @@ static int ibmvnic_remove(struct vio_dev *dev)
 
 	rtnl_unlock();
 	mutex_destroy(&adapter->fw_lock);
-	device_remove_file(&dev->dev, &dev_attr_failover);
+	sysfs_remove_groups(&dev->dev.kobj, dev_attr_groups);
 	free_netdev(netdev);
 	dev_set_drvdata(&dev->dev, NULL);
 
 	return 0;
 }
 
+static struct device_attribute dev_attr_failover;
+
 static ssize_t failover_store(struct device *dev, struct device_attribute *attr,
 			      const char *buf, size_t count)
 {
@@ -5237,6 +5236,20 @@ static ssize_t failover_store(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR_WO(failover);
 
+static struct attribute *dev_attrs[] = {
+	&dev_attr_failover.attr,
+	NULL,
+};
+
+static struct attribute_group dev_attr_group = {
+	.attrs = dev_attrs,
+};
+
+static const struct attribute_group *dev_attr_groups[] = {
+	&dev_attr_group,
+	NULL,
+};
+
 static unsigned long ibmvnic_get_desired_dma(struct vio_dev *vdev)
 {
 	struct net_device *netdev = dev_get_drvdata(&vdev->dev);
-- 
1.8.3.1

Powered by blists - more mailing lists