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

Only compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Cc: Tom Tucker <tom@opengridcomputing.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/infiniband/hw/amso1100/c2_qp.c

index 28cd5cb51859629edb9cffcb1f162832fee91ea6..0ab826b280b27d4d9223ed27d7f3e36c41a831e2 100644 (file)
@@ -382,14 +382,17 @@ static int c2_alloc_qpn(struct c2_dev *c2dev, struct c2_qp *qp)
 {
        int ret;
 
-        do {
-               spin_lock_irq(&c2dev->qp_table.lock);
-               ret = idr_get_new_above(&c2dev->qp_table.idr, qp,
-                                       c2dev->qp_table.last++, &qp->qpn);
-               spin_unlock_irq(&c2dev->qp_table.lock);
-        } while ((ret == -EAGAIN) &&
-                idr_pre_get(&c2dev->qp_table.idr, GFP_KERNEL));
-       return ret;
+       idr_preload(GFP_KERNEL);
+       spin_lock_irq(&c2dev->qp_table.lock);
+
+       ret = idr_alloc(&c2dev->qp_table.idr, qp, c2dev->qp_table.last++, 0,
+                       GFP_NOWAIT);
+       if (ret >= 0)
+               qp->qpn = ret;
+
+       spin_unlock_irq(&c2dev->qp_table.lock);
+       idr_preload_end();
+       return ret < 0 ? ret : 0;
 }
 
 static void c2_free_qpn(struct c2_dev *c2dev, int qpn)