]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
IB/qib: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Thu, 7 Feb 2013 01:31:42 +0000 (12:31 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 18 Feb 2013 05:47:33 +0000 (16:47 +1100)
Convert to the much saner new idr interface.

Only compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Mike Marciniszyn <infinipath@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/infiniband/hw/qib/qib_init.c

index ddf066d9abb6018ef167fbe4e1e25b4c487d7ab2..50e33aa0b4e39628c5de95e314d57de68bbc4be5 100644 (file)
@@ -1060,22 +1060,23 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
        struct qib_devdata *dd;
        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);
        if (!dd) {
                dd = ERR_PTR(-ENOMEM);
                goto bail;
        }
 
+       idr_preload(GFP_KERNEL);
        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);
+       }
+
        spin_unlock_irqrestore(&qib_devs_lock, flags);
+       idr_preload_end();
 
        if (ret < 0) {
                qib_early_err(&pdev->dev,
@@ -1180,11 +1181,6 @@ static int __init qlogic_ib_init(void)
         * the PCI subsystem.
         */
        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);
        if (ret < 0) {
@@ -1199,7 +1195,6 @@ static int __init qlogic_ib_init(void)
 
 bail_unit:
        idr_destroy(&qib_unit_table);
-bail_cq_wq:
        destroy_workqueue(qib_cq_wq);
 bail_dev:
        qib_dev_cleanup();