aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorAlexander Chiang <achiang@hp.com>2010-02-02 14:07:59 -0500
committerRoland Dreier <rolandd@cisco.com>2010-02-24 13:23:40 -0500
commit38707980c42c58e2d00b34ecaa40cf5207bdd9d1 (patch)
tree4cfaea86bc627a219313a2905f89cbab19552948 /drivers/infiniband/core
parent2a72f212263701b927559f6850446421d5906c41 (diff)
IB/uverbs: Use stack variable 'devnum' in ib_uverbs_add_one
This change is not useful by itself, but it sets us up for a future change that allows us to dynamically allocate device numbers in case we have more than IB_UVERBS_MAX_DEVICES in the system. Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/uverbs_main.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 3f11292dda13..acae9ed05728 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -730,6 +730,7 @@ static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
730 730
731static void ib_uverbs_add_one(struct ib_device *device) 731static void ib_uverbs_add_one(struct ib_device *device)
732{ 732{
733 int devnum;
733 struct ib_uverbs_device *uverbs_dev; 734 struct ib_uverbs_device *uverbs_dev;
734 735
735 if (!device->alloc_ucontext) 736 if (!device->alloc_ucontext)
@@ -743,12 +744,13 @@ static void ib_uverbs_add_one(struct ib_device *device)
743 init_completion(&uverbs_dev->comp); 744 init_completion(&uverbs_dev->comp);
744 745
745 spin_lock(&map_lock); 746 spin_lock(&map_lock);
746 uverbs_dev->devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES); 747 devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES);
747 if (uverbs_dev->devnum >= IB_UVERBS_MAX_DEVICES) { 748 if (devnum >= IB_UVERBS_MAX_DEVICES) {
748 spin_unlock(&map_lock); 749 spin_unlock(&map_lock);
749 goto err; 750 goto err;
750 } 751 }
751 set_bit(uverbs_dev->devnum, dev_map); 752 uverbs_dev->devnum = devnum;
753 set_bit(devnum, dev_map);
752 spin_unlock(&map_lock); 754 spin_unlock(&map_lock);
753 755
754 uverbs_dev->ib_dev = device; 756 uverbs_dev->ib_dev = device;
@@ -758,7 +760,7 @@ static void ib_uverbs_add_one(struct ib_device *device)
758 uverbs_dev->cdev.owner = THIS_MODULE; 760 uverbs_dev->cdev.owner = THIS_MODULE;
759 uverbs_dev->cdev.ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; 761 uverbs_dev->cdev.ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops;
760 kobject_set_name(&uverbs_dev->cdev.kobj, "uverbs%d", uverbs_dev->devnum); 762 kobject_set_name(&uverbs_dev->cdev.kobj, "uverbs%d", uverbs_dev->devnum);
761 if (cdev_add(&uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) 763 if (cdev_add(&uverbs_dev->cdev, IB_UVERBS_BASE_DEV + devnum, 1))
762 goto err_cdev; 764 goto err_cdev;
763 765
764 uverbs_dev->dev = device_create(uverbs_class, device->dma_device, 766 uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
@@ -781,7 +783,7 @@ err_class:
781 783
782err_cdev: 784err_cdev:
783 cdev_del(&uverbs_dev->cdev); 785 cdev_del(&uverbs_dev->cdev);
784 clear_bit(uverbs_dev->devnum, dev_map); 786 clear_bit(devnum, dev_map);
785 787
786err: 788err:
787 kref_put(&uverbs_dev->ref, ib_uverbs_release_dev); 789 kref_put(&uverbs_dev->ref, ib_uverbs_release_dev);