diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:20 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:16 -0500 |
commit | e8d4dd606bbd45bad2c4b867d5d91c284cd2828e (patch) | |
tree | 184c1c443049d3d3844c20c982acd8a7e770728a /drivers/infiniband/hw/cxgb4 | |
parent | 6fa780095f058f0960f220754217701a53a9e403 (diff) |
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>
Diffstat (limited to 'drivers/infiniband/hw/cxgb4')
-rw-r--r-- | drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h index 4c07fc069766..7eec5e13fa8c 100644 --- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h +++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h | |||
@@ -260,20 +260,21 @@ static inline int _insert_handle(struct c4iw_dev *rhp, struct idr *idr, | |||
260 | void *handle, u32 id, int lock) | 260 | void *handle, u32 id, int lock) |
261 | { | 261 | { |
262 | int ret; | 262 | int ret; |
263 | int newid; | ||
264 | 263 | ||
265 | do { | 264 | if (lock) { |
266 | if (!idr_pre_get(idr, lock ? GFP_KERNEL : GFP_ATOMIC)) | 265 | idr_preload(GFP_KERNEL); |
267 | return -ENOMEM; | 266 | spin_lock_irq(&rhp->lock); |
268 | if (lock) | 267 | } |
269 | spin_lock_irq(&rhp->lock); | 268 | |
270 | ret = idr_get_new_above(idr, handle, id, &newid); | 269 | ret = idr_alloc(idr, handle, id, id + 1, GFP_ATOMIC); |
271 | BUG_ON(!ret && newid != id); | 270 | |
272 | if (lock) | 271 | if (lock) { |
273 | spin_unlock_irq(&rhp->lock); | 272 | spin_unlock_irq(&rhp->lock); |
274 | } while (ret == -EAGAIN); | 273 | idr_preload_end(); |
275 | 274 | } | |
276 | return ret; | 275 | |
276 | BUG_ON(ret == -ENOSPC); | ||
277 | return ret < 0 ? ret : 0; | ||
277 | } | 278 | } |
278 | 279 | ||
279 | static inline int insert_handle(struct c4iw_dev *rhp, struct idr *idr, | 280 | static inline int insert_handle(struct c4iw_dev *rhp, struct idr *idr, |