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>
This commit is contained in:
parent
5767198a14
commit
5f8f549900
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue