IB/cxgb4: convert to idr_alloc()

Convert to the much saner new idr interface.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Tejun Heo 2013-02-27 17:04:20 -08:00 committed by Linus Torvalds
parent 6fa780095f
commit e8d4dd606b
1 changed files with 13 additions and 12 deletions

View File

@ -260,20 +260,21 @@ static inline int _insert_handle(struct c4iw_dev *rhp, struct idr *idr,
void *handle, u32 id, int lock) void *handle, u32 id, int lock)
{ {
int ret; int ret;
int newid;
do { if (lock) {
if (!idr_pre_get(idr, lock ? GFP_KERNEL : GFP_ATOMIC)) idr_preload(GFP_KERNEL);
return -ENOMEM;
if (lock)
spin_lock_irq(&rhp->lock); spin_lock_irq(&rhp->lock);
ret = idr_get_new_above(idr, handle, id, &newid); }
BUG_ON(!ret && newid != id);
if (lock)
spin_unlock_irq(&rhp->lock);
} while (ret == -EAGAIN);
return ret; ret = idr_alloc(idr, handle, id, id + 1, GFP_ATOMIC);
if (lock) {
spin_unlock_irq(&rhp->lock);
idr_preload_end();
}
BUG_ON(ret == -ENOSPC);
return ret < 0 ? ret : 0;
} }
static inline int insert_handle(struct c4iw_dev *rhp, struct idr *idr, static inline int insert_handle(struct c4iw_dev *rhp, struct idr *idr,