Commit 5c213f86 authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds

IB/ipath: convert to idr_alloc()

Convert to the much saner new idr interface.

[yongjun_wei@trendmicro.com.cn: use GFP_NOWAIT under spin lock]
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent cbbbce1d
...@@ -194,11 +194,6 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev) ...@@ -194,11 +194,6 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
struct ipath_devdata *dd; struct ipath_devdata *dd;
int ret; int ret;
if (!idr_pre_get(&unit_table, GFP_KERNEL)) {
dd = ERR_PTR(-ENOMEM);
goto bail;
}
dd = vzalloc(sizeof(*dd)); dd = vzalloc(sizeof(*dd));
if (!dd) { if (!dd) {
dd = ERR_PTR(-ENOMEM); dd = ERR_PTR(-ENOMEM);
...@@ -206,9 +201,10 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev) ...@@ -206,9 +201,10 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
} }
dd->ipath_unit = -1; dd->ipath_unit = -1;
idr_preload(GFP_KERNEL);
spin_lock_irqsave(&ipath_devs_lock, flags); spin_lock_irqsave(&ipath_devs_lock, flags);
ret = idr_get_new(&unit_table, dd, &dd->ipath_unit); ret = idr_alloc(&unit_table, dd, 0, 0, GFP_NOWAIT);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR IPATH_DRV_NAME printk(KERN_ERR IPATH_DRV_NAME
": Could not allocate unit ID: error %d\n", -ret); ": 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,6 +212,7 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
dd = ERR_PTR(ret); dd = ERR_PTR(ret);
goto bail_unlock; goto bail_unlock;
} }
dd->ipath_unit = ret;
dd->pcidev = pdev; dd->pcidev = pdev;
pci_set_drvdata(pdev, dd); pci_set_drvdata(pdev, dd);
...@@ -224,7 +221,7 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev) ...@@ -224,7 +221,7 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
bail_unlock: bail_unlock:
spin_unlock_irqrestore(&ipath_devs_lock, flags); spin_unlock_irqrestore(&ipath_devs_lock, flags);
idr_preload_end();
bail: bail:
return dd; return dd;
} }
...@@ -2503,11 +2500,6 @@ static int __init infinipath_init(void) ...@@ -2503,11 +2500,6 @@ static int __init infinipath_init(void)
* the PCI subsystem. * the PCI subsystem.
*/ */
idr_init(&unit_table); idr_init(&unit_table);
if (!idr_pre_get(&unit_table, GFP_KERNEL)) {
printk(KERN_ERR IPATH_DRV_NAME ": idr_pre_get() failed\n");
ret = -ENOMEM;
goto bail;
}
ret = pci_register_driver(&ipath_driver); ret = pci_register_driver(&ipath_driver);
if (ret < 0) { if (ret < 0) {
......
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