]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
IB/cxgb3: 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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/infiniband/hw/cxgb3/iwch.h

index a1c44578e0394bfafc8b0c5b48559edd91b33b1a..837862287a298abf978b34e6a590ccf13213b89f 100644 (file)
@@ -153,19 +153,17 @@ static inline int insert_handle(struct iwch_dev *rhp, struct idr *idr,
                                void *handle, u32 id)
 {
        int ret;
-       int newid;
-
-       do {
-               if (!idr_pre_get(idr, GFP_KERNEL)) {
-                       return -ENOMEM;
-               }
-               spin_lock_irq(&rhp->lock);
-               ret = idr_get_new_above(idr, handle, id, &newid);
-               BUG_ON(newid != id);
-               spin_unlock_irq(&rhp->lock);
-       } while (ret == -EAGAIN);
-
-       return ret;
+
+       idr_preload(GFP_KERNEL);
+       spin_lock_irq(&rhp->lock);
+
+       ret = idr_alloc(idr, handle, id, id + 1, GFP_NOWAIT);
+
+       spin_unlock_irq(&rhp->lock);
+       idr_preload_end();
+
+       BUG_ON(ret == -ENOSPC);
+       return ret < 0 ? ret : 0;
 }
 
 static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id)