aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ipath/ipath_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_driver.c')
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index 7b371f545ece..bd0caedafe99 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -194,11 +194,6 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
194 struct ipath_devdata *dd; 194 struct ipath_devdata *dd;
195 int ret; 195 int ret;
196 196
197 if (!idr_pre_get(&unit_table, GFP_KERNEL)) {
198 dd = ERR_PTR(-ENOMEM);
199 goto bail;
200 }
201
202 dd = vzalloc(sizeof(*dd)); 197 dd = vzalloc(sizeof(*dd));
203 if (!dd) { 198 if (!dd) {
204 dd = ERR_PTR(-ENOMEM); 199 dd = ERR_PTR(-ENOMEM);
@@ -206,9 +201,10 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
206 } 201 }
207 dd->ipath_unit = -1; 202 dd->ipath_unit = -1;
208 203
204 idr_preload(GFP_KERNEL);
209 spin_lock_irqsave(&ipath_devs_lock, flags); 205 spin_lock_irqsave(&ipath_devs_lock, flags);
210 206
211 ret = idr_get_new(&unit_table, dd, &dd->ipath_unit); 207 ret = idr_alloc(&unit_table, dd, 0, 0, GFP_NOWAIT);
212 if (ret < 0) { 208 if (ret < 0) {
213 printk(KERN_ERR IPATH_DRV_NAME 209 printk(KERN_ERR IPATH_DRV_NAME
214 ": Could not allocate unit ID: error %d\n", -ret); 210 ": Could not allocate unit ID: error %d\n", -ret);
@@ -216,6 +212,7 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
216 dd = ERR_PTR(ret); 212 dd = ERR_PTR(ret);
217 goto bail_unlock; 213 goto bail_unlock;
218 } 214 }
215 dd->ipath_unit = ret;
219 216
220 dd->pcidev = pdev; 217 dd->pcidev = pdev;
221 pci_set_drvdata(pdev, dd); 218 pci_set_drvdata(pdev, dd);
@@ -224,7 +221,7 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
224 221
225bail_unlock: 222bail_unlock:
226 spin_unlock_irqrestore(&ipath_devs_lock, flags); 223 spin_unlock_irqrestore(&ipath_devs_lock, flags);
227 224 idr_preload_end();
228bail: 225bail:
229 return dd; 226 return dd;
230} 227}
@@ -2503,11 +2500,6 @@ static int __init infinipath_init(void)
2503 * the PCI subsystem. 2500 * the PCI subsystem.
2504 */ 2501 */
2505 idr_init(&unit_table); 2502 idr_init(&unit_table);
2506 if (!idr_pre_get(&unit_table, GFP_KERNEL)) {
2507 printk(KERN_ERR IPATH_DRV_NAME ": idr_pre_get() failed\n");
2508 ret = -ENOMEM;
2509 goto bail;
2510 }
2511 2503
2512 ret = pci_register_driver(&ipath_driver); 2504 ret = pci_register_driver(&ipath_driver);
2513 if (ret < 0) { 2505 if (ret < 0) {