Commit 6fa78009 authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds

IB/cxgb3: convert to idr_alloc()

Convert to the much saner new idr interface.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Reviewed-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ac1d6829
...@@ -153,19 +153,17 @@ static inline int insert_handle(struct iwch_dev *rhp, struct idr *idr, ...@@ -153,19 +153,17 @@ static inline int insert_handle(struct iwch_dev *rhp, struct idr *idr,
void *handle, u32 id) void *handle, u32 id)
{ {
int ret; int ret;
int newid;
idr_preload(GFP_KERNEL);
do { spin_lock_irq(&rhp->lock);
if (!idr_pre_get(idr, GFP_KERNEL)) {
return -ENOMEM; ret = idr_alloc(idr, handle, id, id + 1, GFP_NOWAIT);
}
spin_lock_irq(&rhp->lock); spin_unlock_irq(&rhp->lock);
ret = idr_get_new_above(idr, handle, id, &newid); idr_preload_end();
BUG_ON(newid != id);
spin_unlock_irq(&rhp->lock); BUG_ON(ret == -ENOSPC);
} while (ret == -EAGAIN); return ret < 0 ? ret : 0;
return ret;
} }
static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id) static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id)
......
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