summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2018-12-21 16:19:27 +0200
committerJason Gunthorpe <jgg@mellanox.com>2018-12-21 11:39:41 -0700
commit75bf8a2a2f6b0def50009a631ea2f22f0143ba6c (patch)
tree474d615536dca6bdc44d4fe28e9c5d0e1ab3b8ca /drivers/infiniband
parentcdb53b65ae1b3beac2aaddf6c2d0cef798863466 (diff)
downloadlinux-75bf8a2a2f6b0def50009a631ea2f22f0143ba6c.tar.bz2
IB/umad: Start using dev_groups of class
Start using core defined dev_groups of a class which allows to add device attributes to the core kernel and simplify the umad module. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Jack Morgenstein <jackm@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/user_mad.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 7c95a35910f4..de8d31ab8945 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1123,7 +1123,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);
@@ -1133,9 +1133,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);
@@ -1145,7 +1145,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)
{
@@ -1169,6 +1176,7 @@ static struct class umad_class = {
.name = "infiniband_mad",
.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);