diff options
author | Alexander Chiang <achiang@hp.com> | 2010-02-02 14:08:55 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2010-02-24 13:23:47 -0500 |
commit | dd08f702dd773004b81aeddcd120b052a42710c3 (patch) | |
tree | bfe2817d500fdfec86363f5a5da188d6c94b374c /drivers/infiniband | |
parent | d3f2c67f2d10675f45b0d9257269420e9f59aa1a (diff) |
IB/ucm: Use stack variable 'devnum' in ib_ucm_add_one
This change is not useful by itself, but sets us up for a future
change that allows us to dynamically allocate device numbers in case
we have more than IB_UCM_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')
-rw-r--r-- | drivers/infiniband/core/ucm.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index f504c9b00c1b..7ff3300a86ca 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -1239,6 +1239,7 @@ static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); | |||
1239 | 1239 | ||
1240 | static void ib_ucm_add_one(struct ib_device *device) | 1240 | static void ib_ucm_add_one(struct ib_device *device) |
1241 | { | 1241 | { |
1242 | int devnum; | ||
1242 | struct ib_ucm_device *ucm_dev; | 1243 | struct ib_ucm_device *ucm_dev; |
1243 | 1244 | ||
1244 | if (!device->alloc_ucontext || | 1245 | if (!device->alloc_ucontext || |
@@ -1251,16 +1252,17 @@ static void ib_ucm_add_one(struct ib_device *device) | |||
1251 | 1252 | ||
1252 | ucm_dev->ib_dev = device; | 1253 | ucm_dev->ib_dev = device; |
1253 | 1254 | ||
1254 | ucm_dev->devnum = find_first_zero_bit(dev_map, IB_UCM_MAX_DEVICES); | 1255 | devnum = find_first_zero_bit(dev_map, IB_UCM_MAX_DEVICES); |
1255 | if (ucm_dev->devnum >= IB_UCM_MAX_DEVICES) | 1256 | if (devnum >= IB_UCM_MAX_DEVICES) |
1256 | goto err; | 1257 | goto err; |
1257 | 1258 | ||
1258 | set_bit(ucm_dev->devnum, dev_map); | 1259 | ucm_dev->devnum = devnum; |
1260 | set_bit(devnum, dev_map); | ||
1259 | 1261 | ||
1260 | cdev_init(&ucm_dev->cdev, &ucm_fops); | 1262 | cdev_init(&ucm_dev->cdev, &ucm_fops); |
1261 | ucm_dev->cdev.owner = THIS_MODULE; | 1263 | ucm_dev->cdev.owner = THIS_MODULE; |
1262 | kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum); | 1264 | kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum); |
1263 | if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) | 1265 | if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + devnum, 1)) |
1264 | goto err; | 1266 | goto err; |
1265 | 1267 | ||
1266 | ucm_dev->dev.class = &cm_class; | 1268 | ucm_dev->dev.class = &cm_class; |
@@ -1281,7 +1283,7 @@ err_dev: | |||
1281 | device_unregister(&ucm_dev->dev); | 1283 | device_unregister(&ucm_dev->dev); |
1282 | err_cdev: | 1284 | err_cdev: |
1283 | cdev_del(&ucm_dev->cdev); | 1285 | cdev_del(&ucm_dev->cdev); |
1284 | clear_bit(ucm_dev->devnum, dev_map); | 1286 | clear_bit(devnum, dev_map); |
1285 | err: | 1287 | err: |
1286 | kfree(ucm_dev); | 1288 | kfree(ucm_dev); |
1287 | return; | 1289 | return; |