diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/idr.c | 5 |
1 files changed, 4 insertions, 1 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; |