Commit e155755e authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

RDMA/core: Use simpler device_del() instead of device_unregister()

Instead of holding extra reference using get_device() that
device_unregister() releases, simplify it as below.

device_add() balances with device_del().  device_initialize() balances
with put_device(), always via ib_dealloc_device().
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent cfe876d8
...@@ -369,6 +369,7 @@ void ib_dealloc_device(struct ib_device *device) ...@@ -369,6 +369,7 @@ void ib_dealloc_device(struct ib_device *device)
WARN_ON(!xa_empty(&device->client_data)); WARN_ON(!xa_empty(&device->client_data));
WARN_ON(refcount_read(&device->refcount)); WARN_ON(refcount_read(&device->refcount));
rdma_restrack_clean(device); rdma_restrack_clean(device);
/* Balances with device_initialize */
put_device(&device->dev); put_device(&device->dev);
} }
EXPORT_SYMBOL(ib_dealloc_device); EXPORT_SYMBOL(ib_dealloc_device);
......
...@@ -1351,15 +1351,12 @@ int ib_device_register_sysfs(struct ib_device *device) ...@@ -1351,15 +1351,12 @@ int ib_device_register_sysfs(struct ib_device *device)
void ib_device_unregister_sysfs(struct ib_device *device) void ib_device_unregister_sysfs(struct ib_device *device)
{ {
/* Hold device until ib_dealloc_device() */
get_device(&device->dev);
free_port_list_attributes(device); free_port_list_attributes(device);
if (device->hw_stats) { if (device->hw_stats) {
kfree(device->hw_stats); kfree(device->hw_stats);
free_hsag(&device->dev.kobj, device->hw_stats_ag); free_hsag(&device->dev.kobj, device->hw_stats_ag);
} }
/* Balances with device_add */
device_unregister(&device->dev); device_del(&device->dev);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment