diff options
Diffstat (limited to 'lib/idr.c')
| -rw-r--r-- | lib/idr.c | 7 |
1 files changed, 5 insertions, 2 deletions
| @@ -445,6 +445,7 @@ EXPORT_SYMBOL(idr_remove); | |||
| 445 | void idr_remove_all(struct idr *idp) | 445 | void idr_remove_all(struct idr *idp) |
| 446 | { | 446 | { |
| 447 | int n, id, max; | 447 | int n, id, max; |
| 448 | int bt_mask; | ||
| 448 | struct idr_layer *p; | 449 | struct idr_layer *p; |
| 449 | struct idr_layer *pa[MAX_LEVEL]; | 450 | struct idr_layer *pa[MAX_LEVEL]; |
| 450 | struct idr_layer **paa = &pa[0]; | 451 | struct idr_layer **paa = &pa[0]; |
| @@ -462,8 +463,10 @@ void idr_remove_all(struct idr *idp) | |||
| 462 | p = p->ary[(id >> n) & IDR_MASK]; | 463 | p = p->ary[(id >> n) & IDR_MASK]; |
| 463 | } | 464 | } |
| 464 | 465 | ||
| 466 | bt_mask = id; | ||
| 465 | id += 1 << n; | 467 | id += 1 << n; |
| 466 | while (n < fls(id)) { | 468 | /* Get the highest bit that the above add changed from 0->1. */ |
| 469 | while (n < fls(id ^ bt_mask)) { | ||
| 467 | if (p) | 470 | if (p) |
| 468 | free_layer(p); | 471 | free_layer(p); |
| 469 | n += IDR_BITS; | 472 | n += IDR_BITS; |
| @@ -623,7 +626,7 @@ void *idr_get_next(struct idr *idp, int *nextidp) | |||
| 623 | } | 626 | } |
| 624 | return NULL; | 627 | return NULL; |
| 625 | } | 628 | } |
| 626 | 629 | EXPORT_SYMBOL(idr_get_next); | |
| 627 | 630 | ||
| 628 | 631 | ||
| 629 | /** | 632 | /** |
