diff options
Diffstat (limited to 'lib/idr.c')
-rw-r--r-- | lib/idr.c | 30 |
1 files changed, 9 insertions, 21 deletions
@@ -143,7 +143,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa) | |||
143 | /* if already at the top layer, we need to grow */ | 143 | /* if already at the top layer, we need to grow */ |
144 | if (!(p = pa[l])) { | 144 | if (!(p = pa[l])) { |
145 | *starting_id = id; | 145 | *starting_id = id; |
146 | return -2; | 146 | return IDR_NEED_TO_GROW; |
147 | } | 147 | } |
148 | 148 | ||
149 | /* If we need to go up one layer, continue the | 149 | /* If we need to go up one layer, continue the |
@@ -160,7 +160,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa) | |||
160 | id = ((id >> sh) ^ n ^ m) << sh; | 160 | id = ((id >> sh) ^ n ^ m) << sh; |
161 | } | 161 | } |
162 | if ((id >= MAX_ID_BIT) || (id < 0)) | 162 | if ((id >= MAX_ID_BIT) || (id < 0)) |
163 | return -3; | 163 | return IDR_NOMORE_SPACE; |
164 | if (l == 0) | 164 | if (l == 0) |
165 | break; | 165 | break; |
166 | /* | 166 | /* |
@@ -229,7 +229,7 @@ build_up: | |||
229 | idp->top = p; | 229 | idp->top = p; |
230 | idp->layers = layers; | 230 | idp->layers = layers; |
231 | v = sub_alloc(idp, &id, pa); | 231 | v = sub_alloc(idp, &id, pa); |
232 | if (v == -2) | 232 | if (v == IDR_NEED_TO_GROW) |
233 | goto build_up; | 233 | goto build_up; |
234 | return(v); | 234 | return(v); |
235 | } | 235 | } |
@@ -278,12 +278,8 @@ int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) | |||
278 | * This is a cheap hack until the IDR code can be fixed to | 278 | * This is a cheap hack until the IDR code can be fixed to |
279 | * return proper error values. | 279 | * return proper error values. |
280 | */ | 280 | */ |
281 | if (rv < 0) { | 281 | if (rv < 0) |
282 | if (rv == -1) | 282 | return _idr_rc_to_errno(rv); |
283 | return -EAGAIN; | ||
284 | else /* Will be -3 */ | ||
285 | return -ENOSPC; | ||
286 | } | ||
287 | *id = rv; | 283 | *id = rv; |
288 | return 0; | 284 | return 0; |
289 | } | 285 | } |
@@ -313,12 +309,8 @@ int idr_get_new(struct idr *idp, void *ptr, int *id) | |||
313 | * This is a cheap hack until the IDR code can be fixed to | 309 | * This is a cheap hack until the IDR code can be fixed to |
314 | * return proper error values. | 310 | * return proper error values. |
315 | */ | 311 | */ |
316 | if (rv < 0) { | 312 | if (rv < 0) |
317 | if (rv == -1) | 313 | return _idr_rc_to_errno(rv); |
318 | return -EAGAIN; | ||
319 | else /* Will be -3 */ | ||
320 | return -ENOSPC; | ||
321 | } | ||
322 | *id = rv; | 314 | *id = rv; |
323 | return 0; | 315 | return 0; |
324 | } | 316 | } |
@@ -696,12 +688,8 @@ int ida_get_new_above(struct ida *ida, int starting_id, int *p_id) | |||
696 | restart: | 688 | restart: |
697 | /* get vacant slot */ | 689 | /* get vacant slot */ |
698 | t = idr_get_empty_slot(&ida->idr, idr_id, pa); | 690 | t = idr_get_empty_slot(&ida->idr, idr_id, pa); |
699 | if (t < 0) { | 691 | if (t < 0) |
700 | if (t == -1) | 692 | return _idr_rc_to_errno(t); |
701 | return -EAGAIN; | ||
702 | else /* will be -3 */ | ||
703 | return -ENOSPC; | ||
704 | } | ||
705 | 693 | ||
706 | if (t * IDA_BITMAP_BITS >= MAX_ID_BIT) | 694 | if (t * IDA_BITMAP_BITS >= MAX_ID_BIT) |
707 | return -ENOSPC; | 695 | return -ENOSPC; |