Merge branch 'mlx4'
[cascardo/linux.git] / lib / idr.c
index 36ff732..39158ab 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
  * pointer or what ever, we treat it as a (void *).  You can pass this
  * id to a user for him to pass back at a later time.  You then pass
  * that id to this code and it returns your pointer.
-
- * You can release ids at any time. When all ids are released, most of
- * the memory is returned (we keep MAX_IDR_FREE) in a local pool so we
- * don't need to go to the memory "store" during an id allocate, just
- * so you don't need to be too concerned about locking and conflicts
- * with the slab allocator.
  */
 
 #ifndef TEST                        // to test in user space...
@@ -151,7 +145,7 @@ static void idr_layer_rcu_free(struct rcu_head *head)
 
 static inline void free_layer(struct idr *idr, struct idr_layer *p)
 {
-       if (idr->hint && idr->hint == p)
+       if (idr->hint == p)
                RCU_INIT_POINTER(idr->hint, NULL);
        call_rcu(&p->rcu_head, idr_layer_rcu_free);
 }
@@ -584,16 +578,6 @@ void idr_remove(struct idr *idp, int id)
                bitmap_clear(to_free->bitmap, 0, IDR_SIZE);
                free_layer(idp, to_free);
        }
-       while (idp->id_free_cnt >= MAX_IDR_FREE) {
-               p = get_from_free_list(idp);
-               /*
-                * Note: we don't call the rcu callback here, since the only
-                * layers that fall into the freelist are those that have been
-                * preallocated.
-                */
-               kmem_cache_free(idr_layer_cache, p);
-       }
-       return;
 }
 EXPORT_SYMBOL(idr_remove);
 
@@ -814,10 +798,10 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
 
        p = idp->top;
        if (!p)
-               return ERR_PTR(-EINVAL);
+               return ERR_PTR(-ENOENT);
 
        if (id > idr_max(p->layer + 1))
-               return ERR_PTR(-EINVAL);
+               return ERR_PTR(-ENOENT);
 
        n = p->layer * IDR_BITS;
        while ((n > 0) && p) {