summaryrefslogtreecommitdiff
path: root/drivers/infiniband/core/device.c
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2019-02-13 19:23:06 +0200
committerJason Gunthorpe <jgg@mellanox.com>2019-02-15 21:57:14 -0700
commit5f8f5499005c51656645a011bca81ffb66fcaaca (patch)
tree7cbe87ad40981de4ff096a28d912dc463b90c03c /drivers/infiniband/core/device.c
parent5767198a14c796354e8a96fcdc7db12ee46a0623 (diff)
RDMA/core: Move device addition deletion to device.c
Move core device addition and removal from sysfs.c to device.c as device.c is more appropriate place for device management. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core/device.c')
-rw-r--r--drivers/infiniband/core/device.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 46d237ce83de..3eddc6e67a16 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -341,6 +341,8 @@ struct ib_device *_ib_alloc_device(size_t size)
rdma_restrack_init(device);
device->dev.class = &ib_class;
+ device->groups[0] = &ib_dev_attr_group;
+ device->dev.groups = device->groups;
device_initialize(&device->dev);
INIT_LIST_HEAD(&device->event_handler_list);
@@ -766,11 +768,15 @@ int ib_register_device(struct ib_device *device, const char *name)
ib_device_register_rdmacg(device);
+ ret = device_add(&device->dev);
+ if (ret)
+ goto cg_cleanup;
+
ret = ib_device_register_sysfs(device);
if (ret) {
dev_warn(&device->dev,
"Couldn't register device with driver model\n");
- goto cg_cleanup;
+ goto dev_cleanup;
}
ret = enable_device(device);
@@ -781,6 +787,8 @@ int ib_register_device(struct ib_device *device, const char *name)
sysfs_cleanup:
ib_device_unregister_sysfs(device);
+dev_cleanup:
+ device_del(&device->dev);
cg_cleanup:
ib_device_unregister_rdmacg(device);
ib_cache_cleanup_one(device);
@@ -800,6 +808,7 @@ void ib_unregister_device(struct ib_device *device)
{
disable_device(device);
ib_device_unregister_sysfs(device);
+ device_del(&device->dev);
ib_device_unregister_rdmacg(device);
ib_cache_cleanup_one(device);
release_name(device);