-/**
- * idr_replace - replace pointer for given id
- * @idp: idr handle
- * @ptr: pointer you want associated with the id
- * @id: lookup key
- *
- * Replace the pointer registered with an id and return the old value.
- * A -ENOENT return indicates that @id was not found.
- * A -EINVAL return indicates that @id was not within valid constraints.
- *
- * The caller must serialize vs idr_find(), idr_get_new(), and idr_remove().
- */
-void *idr_replace(struct idr *idp, void *ptr, int id)
-{
- int n;
- struct idr_layer *p, *old_p;
-
- n = idp->layers * IDR_BITS;
- p = idp->top;
-
- id &= MAX_ID_MASK;
-
- if (id >= (1 << n))
- return ERR_PTR(-EINVAL);
-
- n -= IDR_BITS;
- while ((n > 0) && p) {
- p = p->ary[(id >> n) & IDR_MASK];
- n -= IDR_BITS;
- }
-
- n = id & IDR_MASK;
- if (unlikely(p == NULL || !test_bit(n, &p->bitmap)))
- return ERR_PTR(-ENOENT);
-
- old_p = p->ary[n];
- p->ary[n] = ptr;
-
- return old_p;
-}
-EXPORT_SYMBOL(idr_replace);
-