Skip to content

Commit

Permalink
RDMA/core: Use simpler device_del() instead of device_unregister()
Browse files Browse the repository at this point in the history
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: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Parav Pandit authored and Jason Gunthorpe committed Feb 16, 2019
1 parent cfe876d commit e155755
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions drivers/infiniband/core/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ void ib_dealloc_device(struct ib_device *device)
WARN_ON(!xa_empty(&device->client_data));
WARN_ON(refcount_read(&device->refcount));
rdma_restrack_clean(device);
/* Balances with device_initialize */
put_device(&device->dev);
}
EXPORT_SYMBOL(ib_dealloc_device);
Expand Down
7 changes: 2 additions & 5 deletions drivers/infiniband/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,15 +1351,12 @@ int ib_device_register_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);

if (device->hw_stats) {
kfree(device->hw_stats);
free_hsag(&device->dev.kobj, device->hw_stats_ag);
}

device_unregister(&device->dev);
/* Balances with device_add */
device_del(&device->dev);
}

0 comments on commit e155755

Please sign in to comment.