Commit 2a72f212 authored by Alexander Chiang's avatar Alexander Chiang Committed by Roland Dreier

IB/uverbs: Remove dev_table

dev_table's raison d'etre was to associate an inode back to a struct
ib_uverbs_device.

However, now that we've converted ib_uverbs_device to contain an
embedded cdev (instead of a *cdev), we can use the container_of()
macro and cast back to the containing device.

There's no longer any need for dev_table, so get rid of it.
Signed-off-by: default avatarAlex Chiang <achiang@hp.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 055422dd
...@@ -74,7 +74,6 @@ DEFINE_IDR(ib_uverbs_qp_idr); ...@@ -74,7 +74,6 @@ DEFINE_IDR(ib_uverbs_qp_idr);
DEFINE_IDR(ib_uverbs_srq_idr); DEFINE_IDR(ib_uverbs_srq_idr);
static DEFINE_SPINLOCK(map_lock); static DEFINE_SPINLOCK(map_lock);
static struct ib_uverbs_device *dev_table[IB_UVERBS_MAX_DEVICES];
static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES); static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES);
static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file, static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
...@@ -616,14 +615,12 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -616,14 +615,12 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
/* /*
* ib_uverbs_open() does not need the BKL: * ib_uverbs_open() does not need the BKL:
* *
* - dev_table[] accesses are protected by map_lock, the * - the ib_uverbs_device structures are properly reference counted and
* ib_uverbs_device structures are properly reference counted, and
* everything else is purely local to the file being created, so * everything else is purely local to the file being created, so
* races against other open calls are not a problem; * races against other open calls are not a problem;
* - there is no ioctl method to race against; * - there is no ioctl method to race against;
* - the device is added to dev_table[] as the last part of module * - the open method will either immediately run -ENXIO, or all
* initialization, the open method will either immediately run * required initialization will be done.
* -ENXIO, or all required initialization will be done.
*/ */
static int ib_uverbs_open(struct inode *inode, struct file *filp) static int ib_uverbs_open(struct inode *inode, struct file *filp)
{ {
...@@ -631,13 +628,10 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp) ...@@ -631,13 +628,10 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
struct ib_uverbs_file *file; struct ib_uverbs_file *file;
int ret; int ret;
spin_lock(&map_lock); dev = container_of(inode->i_cdev, struct ib_uverbs_device, cdev);
dev = dev_table[iminor(inode) - IB_UVERBS_BASE_MINOR];
if (dev) if (dev)
kref_get(&dev->ref); kref_get(&dev->ref);
spin_unlock(&map_lock); else
if (!dev)
return -ENXIO; return -ENXIO;
if (!try_module_get(dev->ib_dev->owner)) { if (!try_module_get(dev->ib_dev->owner)) {
...@@ -778,10 +772,6 @@ static void ib_uverbs_add_one(struct ib_device *device) ...@@ -778,10 +772,6 @@ static void ib_uverbs_add_one(struct ib_device *device)
if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version)) if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version))
goto err_class; goto err_class;
spin_lock(&map_lock);
dev_table[uverbs_dev->devnum] = uverbs_dev;
spin_unlock(&map_lock);
ib_set_client_data(device, &uverbs_client, uverbs_dev); ib_set_client_data(device, &uverbs_client, uverbs_dev);
return; return;
...@@ -811,10 +801,6 @@ static void ib_uverbs_remove_one(struct ib_device *device) ...@@ -811,10 +801,6 @@ static void ib_uverbs_remove_one(struct ib_device *device)
device_destroy(uverbs_class, uverbs_dev->cdev.dev); device_destroy(uverbs_class, uverbs_dev->cdev.dev);
cdev_del(&uverbs_dev->cdev); cdev_del(&uverbs_dev->cdev);
spin_lock(&map_lock);
dev_table[uverbs_dev->devnum] = NULL;
spin_unlock(&map_lock);
clear_bit(uverbs_dev->devnum, dev_map); clear_bit(uverbs_dev->devnum, dev_map);
kref_put(&uverbs_dev->ref, ib_uverbs_release_dev); kref_put(&uverbs_dev->ref, ib_uverbs_release_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