diff options
author | Parav Pandit <parav@mellanox.com> | 2019-02-13 19:23:06 +0200 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-02-15 21:57:14 -0700 |
commit | 5f8f5499005c51656645a011bca81ffb66fcaaca (patch) | |
tree | 7cbe87ad40981de4ff096a28d912dc463b90c03c | |
parent | 5767198a14c796354e8a96fcdc7db12ee46a0623 (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>
-rw-r--r-- | drivers/infiniband/core/core_priv.h | 2 | ||||
-rw-r--r-- | drivers/infiniband/core/device.c | 11 | ||||
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 14 |
3 files changed, 14 insertions, 13 deletions
diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h index a1826f4c2e23..eeabe9ca8427 100644 --- a/drivers/infiniband/core/core_priv.h +++ b/drivers/infiniband/core/core_priv.h @@ -54,6 +54,8 @@ struct pkey_index_qp_list { struct list_head qp_list; }; +extern const struct attribute_group ib_dev_attr_group; + int ib_device_register_sysfs(struct ib_device *device); void ib_device_unregister_sysfs(struct ib_device *device); int ib_device_rename(struct ib_device *ibdev, const char *name); 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); diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 7e51b406e89a..9335b15c2e38 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -1275,7 +1275,7 @@ static struct attribute *ib_dev_attrs[] = { NULL, }; -static const struct attribute_group dev_attr_group = { +const struct attribute_group ib_dev_attr_group = { .attrs = ib_dev_attrs, }; @@ -1338,18 +1338,10 @@ int ib_device_register_sysfs(struct ib_device *device) { int ret; - device->groups[0] = &dev_attr_group; - device->dev.groups = device->groups; - - ret = device_add(&device->dev); + ret = ib_setup_port_attrs(device); if (ret) return ret; - ret = ib_setup_port_attrs(device); - if (ret) { - device_del(&device->dev); - return ret; - } if (device->ops.alloc_hw_stats) setup_hw_stats(device, NULL, 0); @@ -1363,6 +1355,4 @@ void ib_device_unregister_sysfs(struct ib_device *device) kfree(device->hw_stats); ib_free_port_attrs(device); - /* Balances with device_add */ - device_del(&device->dev); } |