diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:16 -0500 |
commit | 6fa780095f058f0960f220754217701a53a9e403 (patch) | |
tree | cb5bbc2e043f90ffead9a4c8162d2d7aaf02cea9 /drivers/infiniband | |
parent | ac1d68296b2504cd878e328be21eebb6093b7f27 (diff) |
IB/cxgb3: 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')
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch.h | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/infiniband/hw/cxgb3/iwch.h b/drivers/infiniband/hw/cxgb3/iwch.h index a1c44578e039..837862287a29 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, | |||
153 | void *handle, u32 id) | 153 | void *handle, u32 id) |
154 | { | 154 | { |
155 | int ret; | 155 | int ret; |
156 | int newid; | 156 | |
157 | 157 | idr_preload(GFP_KERNEL); | |
158 | do { | 158 | spin_lock_irq(&rhp->lock); |
159 | if (!idr_pre_get(idr, GFP_KERNEL)) { | 159 | |
160 | return -ENOMEM; | 160 | ret = idr_alloc(idr, handle, id, id + 1, GFP_NOWAIT); |
161 | } | 161 | |
162 | spin_lock_irq(&rhp->lock); | 162 | spin_unlock_irq(&rhp->lock); |
163 | ret = idr_get_new_above(idr, handle, id, &newid); | 163 | idr_preload_end(); |
164 | BUG_ON(newid != id); | 164 | |
165 | spin_unlock_irq(&rhp->lock); | 165 | BUG_ON(ret == -ENOSPC); |
166 | } while (ret == -EAGAIN); | 166 | return ret < 0 ? ret : 0; |
167 | |||
168 | return ret; | ||
169 | } | 167 | } |
170 | 168 | ||
171 | static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id) | 169 | static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id) |