[PATCH rdma-next 6/6] IB/umad: Start using dev_groups of class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Parav Pandit <parav@xxxxxxxxxxxx>

Start using core defined dev_groups of a class, which uses the core
kernel to add device attributes, thus simplifying the umad module.

Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx>
Reviewed-by: Jack Morgenstein <jackm@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 drivers/infiniband/core/user_mad.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 34fa6b73e84c..9ff7612b8661 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1125,7 +1125,7 @@ static struct ib_client umad_client = {
 	.remove = ib_umad_remove_one
 };
 
-static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
+static ssize_t ibdev_show(struct device *dev, struct device_attribute *attr,
 			  char *buf)
 {
 	struct ib_umad_port *port = dev_get_drvdata(dev);
@@ -1135,9 +1135,9 @@ static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
 
 	return sprintf(buf, "%s\n", dev_name(&port->ib_dev->dev));
 }
-static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
+static DEVICE_ATTR_RO(ibdev);
 
-static ssize_t show_port(struct device *dev, struct device_attribute *attr,
+static ssize_t port_show(struct device *dev, struct device_attribute *attr,
 			 char *buf)
 {
 	struct ib_umad_port *port = dev_get_drvdata(dev);
@@ -1147,7 +1147,14 @@ static ssize_t show_port(struct device *dev, struct device_attribute *attr,
 
 	return sprintf(buf, "%d\n", port->port_num);
 }
-static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
+static DEVICE_ATTR_RO(port);
+
+static struct attribute *umad_class_dev_attrs[] = {
+	&dev_attr_ibdev.attr,
+	&dev_attr_port.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(umad_class_dev);
 
 static char *umad_devnode(struct device *dev, umode_t *mode)
 {
@@ -1171,6 +1178,7 @@ static struct class umad_class = {
 	.name		= IB_UMAD_CLASS_NAME,
 	.devnode	= umad_devnode,
 	.class_groups	= umad_class_groups,
+	.dev_groups	= umad_class_dev_groups,
 };
 
 static void ib_umad_release_port(struct device *device)
@@ -1229,11 +1237,6 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
 	if (ret)
 		goto err_cdev;
 
-	if (device_create_file(&port->dev, &dev_attr_ibdev))
-		goto err_dev;
-	if (device_create_file(&port->dev, &dev_attr_port))
-		goto err_dev;
-
 	ib_umad_init_port_dev(&port->sm_dev, port, device);
 	port->sm_dev.devt = base_issm;
 	dev_set_name(&port->sm_dev, "issm%d", port->dev_num);
@@ -1244,15 +1247,8 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
 	if (ret)
 		goto err_dev;
 
-	if (device_create_file(&port->sm_dev, &dev_attr_ibdev))
-		goto err_sm_dev;
-	if (device_create_file(&port->sm_dev, &dev_attr_port))
-		goto err_sm_dev;
-
 	return 0;
 
-err_sm_dev:
-	cdev_device_del(&port->sm_cdev, &port->sm_dev);
 err_dev:
 	put_device(&port->sm_dev);
 	cdev_device_del(&port->cdev, &port->dev);
-- 
2.19.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux