Skip to content

Commit

Permalink
IB/cxgb3: convert to idr_alloc()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Feb 28, 2013
1 parent ac1d682 commit 6fa7800
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions drivers/infiniband/hw/cxgb3/iwch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6fa7800

Please sign in to comment.