RDMA/drivers: Use core provided API for registering device attributes

Use rdma_set_device_sysfs_group() to register device attributes and
simplify the driver.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
Parav Pandit
2018-10-11 22:31:54 +03:00
committed by Jason Gunthorpe
szülő d4122f5abe
commit 508a523f6b
23 fájl változott, egészen pontosan 364 új sor hozzáadva és 543 régi sor törölve

Fájl megtekintése

@@ -1148,14 +1148,18 @@ static ssize_t parent_show(struct device *device,
static DEVICE_ATTR_RO(parent);
static struct device_attribute *rxe_dev_attributes[] = {
&dev_attr_parent,
static struct attribute *rxe_dev_attributes[] = {
&dev_attr_parent.attr,
NULL
};
static const struct attribute_group rxe_attr_group = {
.attrs = rxe_dev_attributes,
};
int rxe_register_device(struct rxe_dev *rxe)
{
int err;
int i;
struct ib_device *dev = &rxe->ib_dev;
struct crypto_shash *tfm;
@@ -1259,6 +1263,7 @@ int rxe_register_device(struct rxe_dev *rxe)
}
rxe->tfm = tfm;
rdma_set_device_sysfs_group(dev, &rxe_attr_group);
dev->driver_id = RDMA_DRIVER_RXE;
err = ib_register_device(dev, "rxe%d", NULL);
if (err) {
@@ -1266,19 +1271,8 @@ int rxe_register_device(struct rxe_dev *rxe)
goto err1;
}
for (i = 0; i < ARRAY_SIZE(rxe_dev_attributes); ++i) {
err = device_create_file(&dev->dev, rxe_dev_attributes[i]);
if (err) {
pr_warn("%s failed with error %d for attr number %d\n",
__func__, err, i);
goto err2;
}
}
return 0;
err2:
ib_unregister_device(dev);
err1:
crypto_free_shash(rxe->tfm);
@@ -1287,12 +1281,8 @@ err1:
int rxe_unregister_device(struct rxe_dev *rxe)
{
int i;
struct ib_device *dev = &rxe->ib_dev;
for (i = 0; i < ARRAY_SIZE(rxe_dev_attributes); ++i)
device_remove_file(&dev->dev, rxe_dev_attributes[i]);
ib_unregister_device(dev);
return 0;