Commit 80f22b44 authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds

IB/qib: convert to idr_alloc()

Convert to the much saner new idr interface.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: Mike Marciniszyn <infinipath@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent cffcd59f
...@@ -1060,22 +1060,23 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra) ...@@ -1060,22 +1060,23 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
struct qib_devdata *dd; struct qib_devdata *dd;
int ret; int ret;
if (!idr_pre_get(&qib_unit_table, GFP_KERNEL)) {
dd = ERR_PTR(-ENOMEM);
goto bail;
}
dd = (struct qib_devdata *) ib_alloc_device(sizeof(*dd) + extra); dd = (struct qib_devdata *) ib_alloc_device(sizeof(*dd) + extra);
if (!dd) { if (!dd) {
dd = ERR_PTR(-ENOMEM); dd = ERR_PTR(-ENOMEM);
goto bail; goto bail;
} }
idr_preload(GFP_KERNEL);
spin_lock_irqsave(&qib_devs_lock, flags); spin_lock_irqsave(&qib_devs_lock, flags);
ret = idr_get_new(&qib_unit_table, dd, &dd->unit);
if (ret >= 0) ret = idr_alloc(&qib_unit_table, dd, 0, 0, GFP_NOWAIT);
if (ret >= 0) {
dd->unit = ret;
list_add(&dd->list, &qib_dev_list); list_add(&dd->list, &qib_dev_list);
}
spin_unlock_irqrestore(&qib_devs_lock, flags); spin_unlock_irqrestore(&qib_devs_lock, flags);
idr_preload_end();
if (ret < 0) { if (ret < 0) {
qib_early_err(&pdev->dev, qib_early_err(&pdev->dev,
...@@ -1180,11 +1181,6 @@ static int __init qlogic_ib_init(void) ...@@ -1180,11 +1181,6 @@ static int __init qlogic_ib_init(void)
* the PCI subsystem. * the PCI subsystem.
*/ */
idr_init(&qib_unit_table); idr_init(&qib_unit_table);
if (!idr_pre_get(&qib_unit_table, GFP_KERNEL)) {
pr_err("idr_pre_get() failed\n");
ret = -ENOMEM;
goto bail_cq_wq;
}
ret = pci_register_driver(&qib_driver); ret = pci_register_driver(&qib_driver);
if (ret < 0) { if (ret < 0) {
...@@ -1199,7 +1195,6 @@ static int __init qlogic_ib_init(void) ...@@ -1199,7 +1195,6 @@ static int __init qlogic_ib_init(void)
bail_unit: bail_unit:
idr_destroy(&qib_unit_table); idr_destroy(&qib_unit_table);
bail_cq_wq:
destroy_workqueue(qib_cq_wq); destroy_workqueue(qib_cq_wq);
bail_dev: bail_dev:
qib_dev_cleanup(); qib_dev_cleanup();
......
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