|
@@ -249,7 +249,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa,
|
|
|
id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1;
|
|
id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1;
|
|
|
|
|
|
|
|
/* if already at the top layer, we need to grow */
|
|
/* if already at the top layer, we need to grow */
|
|
|
- if (id >= 1 << (idp->layers * IDR_BITS)) {
|
|
|
|
|
|
|
+ if (id > idr_max(idp->layers)) {
|
|
|
*starting_id = id;
|
|
*starting_id = id;
|
|
|
return -EAGAIN;
|
|
return -EAGAIN;
|
|
|
}
|
|
}
|
|
@@ -811,12 +811,10 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
|
|
|
if (!p)
|
|
if (!p)
|
|
|
return ERR_PTR(-EINVAL);
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
- n = (p->layer+1) * IDR_BITS;
|
|
|
|
|
-
|
|
|
|
|
- if (id >= (1 << n))
|
|
|
|
|
|
|
+ if (id > idr_max(p->layer + 1))
|
|
|
return ERR_PTR(-EINVAL);
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
- n -= IDR_BITS;
|
|
|
|
|
|
|
+ n = p->layer * IDR_BITS;
|
|
|
while ((n > 0) && p) {
|
|
while ((n > 0) && p) {
|
|
|
p = p->ary[(id >> n) & IDR_MASK];
|
|
p = p->ary[(id >> n) & IDR_MASK];
|
|
|
n -= IDR_BITS;
|
|
n -= IDR_BITS;
|