From: Tejun Heo Date: Thu, 28 Feb 2013 01:04:18 +0000 (-0800) Subject: IB/cxgb3: convert to idr_alloc() X-Git-Tag: accepted/tizen/common/20141203.182822~2762^2~81 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6fa780095f058f0960f220754217701a53a9e403;p=platform%2Fkernel%2Flinux-arm64.git IB/cxgb3: convert to idr_alloc() Convert to the much saner new idr interface. Signed-off-by: Tejun Heo Reviewed-by: Steve Wise Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/infiniband/hw/cxgb3/iwch.h b/drivers/infiniband/hw/cxgb3/iwch.h index a1c4457..8378622 100644 --- a/drivers/infiniband/hw/cxgb3/iwch.h +++ b/drivers/infiniband/hw/cxgb3/iwch.h @@ -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)