]> www.infradead.org Git - users/willy/xarray.git/commitdiff
Remove idr_for_each()
authorMatthew Wilcox <willy@infradead.org>
Fri, 15 Feb 2019 19:54:00 +0000 (14:54 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 9 Aug 2019 01:38:16 +0000 (21:38 -0400)
With no more users remaining, delete the function.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
Documentation/core-api/idr.rst
include/linux/idr.h
lib/idr.c
lib/radix-tree.c
tools/testing/radix-tree/idr-test.c

index e81e48909e31953c4d442ed81c54fb35736ab18d..a04a2d5f22d314e8a1df9414fbb468179c38d6ab 100644 (file)
@@ -29,8 +29,7 @@ the pointer you associated with the ID by calling :c:func:`idr_find`
 and free the ID by calling :c:func:`idr_remove`.
 
 To perform an action on all pointers used by the IDR, you can
-either use the callback-based :c:func:`idr_for_each` or the
-iterator-style :c:func:`idr_for_each_entry`.  You may need to use
+use :c:func:`idr_for_each_entry`.  You may need to use
 :c:func:`idr_for_each_entry_continue` to continue an iteration.  You can
 also use :c:func:`idr_get_next` if the iterator doesn't fit your needs.
 
index e805371dd1b2107343334cbacbf6ae76a0240b22..6e556350857a3daf58a35e046376a37deab6eb80 100644 (file)
@@ -84,8 +84,6 @@ struct idr {
 int idr_alloc(struct idr *, void *ptr, int start, int end, gfp_t);
 void *idr_remove(struct idr *, unsigned long id);
 void *idr_find(const struct idr *, unsigned long id);
-int idr_for_each(const struct idr *,
-                int (*fn)(int id, void *p, void *data), void *data);
 void *idr_get_next(struct idr *, int *nextid);
 void idr_destroy(struct idr *);
 
index b11ee953ac28510a3e449caf3d7ce8bba2c7f19d..0182590cc5f728ae34924c5e70664a0bacb3b9d8 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -108,45 +108,6 @@ void *idr_find(const struct idr *idr, unsigned long id)
 }
 EXPORT_SYMBOL_GPL(idr_find);
 
-/**
- * idr_for_each() - Iterate through all stored pointers.
- * @idr: IDR handle.
- * @fn: Function to be called for each pointer.
- * @data: Data passed to callback function.
- *
- * The callback function will be called for each entry in @idr, passing
- * the ID, the entry and @data.
- *
- * If @fn returns anything other than %0, the iteration stops and that
- * value is returned from this function.
- *
- * idr_for_each() can be called concurrently with idr_alloc() and
- * idr_remove() if protected by RCU.  Newly added entries may not be
- * seen and deleted entries may be seen, but adding and removing entries
- * will not cause other entries to be skipped, nor spurious ones to be seen.
- */
-int idr_for_each(const struct idr *idr,
-               int (*fn)(int id, void *p, void *data), void *data)
-{
-       struct radix_tree_iter iter;
-       void __rcu **slot;
-       int base = idr->idr_base;
-
-       radix_tree_for_each_slot(slot, &idr->idr_rt, &iter, 0) {
-               int ret;
-               unsigned long id = iter.index + base;
-
-               if (WARN_ON_ONCE(id > INT_MAX))
-                       break;
-               ret = fn(id, rcu_dereference_raw(*slot), data);
-               if (ret)
-                       return ret;
-       }
-
-       return 0;
-}
-EXPORT_SYMBOL(idr_for_each);
-
 /**
  * idr_get_next() - Find next populated entry.
  * @idr: IDR handle.
index 4a7369612db410e6ce7094b9167a8739741a5b6a..60d92ffd057c428321c45f2603c0e16e9df40126 100644 (file)
@@ -941,7 +941,7 @@ void __rcu **idr_get_free(struct radix_tree_root *root,
  * the data structure containing it may be freed.
  *
  * A typical clean-up sequence for objects stored in an idr tree will use
- * idr_for_each() to free all objects, if necessary, then idr_destroy() to
+ * idr_for_each_entry() to free all objects, if necessary, then idr_destroy() to
  * free the memory used to keep track of those objects.
  */
 void idr_destroy(struct idr *idr)
index ce97e50e8f0f68e1629e18bcd95d677ff54511c9..a62114f74b811a167433e79285aafa6c9bc4608d 100644 (file)
@@ -87,13 +87,14 @@ void idr_get_next_test(int base)
 {
        unsigned long i;
        int nextid;
+       struct item *item;
        DEFINE_IDR(idr);
        idr_init_base(&idr, base);
 
        int indices[] = {4, 7, 9, 15, 65, 128, 1000, 99999, 0};
 
        for(i = 0; indices[i]; i++) {
-               struct item *item = item_create(indices[i], 0);
+               item = item_create(indices[i], 0);
                assert(idr_alloc(&idr, item, indices[i], indices[i+1],
                                 GFP_KERNEL) == indices[i]);
        }
@@ -104,7 +105,8 @@ void idr_get_next_test(int base)
                nextid++;
        }
 
-       idr_for_each(&idr, item_idr_free, &idr);
+       idr_for_each_entry(&idr, item, nextid)
+               item_idr_free(nextid, item, &idr);
        idr_destroy(&idr);
 }
 
@@ -205,10 +207,12 @@ void idr_find_test(void)
 void idr_checks(void)
 {
        unsigned long i;
+       int id;
+       struct item *item;
        DEFINE_IDR(idr);
 
        for (i = 0; i < 10000; i++) {
-               struct item *item = item_create(i, 0);
+               item = item_create(i, 0);
                assert(idr_alloc(&idr, item, 0, 20000, GFP_KERNEL) == i);
        }
 
@@ -219,7 +223,8 @@ void idr_checks(void)
 
        idr_remove(&idr, 3);
 
-       idr_for_each(&idr, item_idr_free, &idr);
+       idr_for_each_entry(&idr, item, id)
+               item_idr_free(id, item, &idr);
        idr_destroy(&idr);
 
        assert(idr_is_empty(&idr));
@@ -235,24 +240,26 @@ void idr_checks(void)
        idr_destroy(&idr);
 
        for (i = INT_MAX - 3UL; i < INT_MAX + 1UL; i++) {
-               struct item *item = item_create(i, 0);
+               item = item_create(i, 0);
                assert(idr_alloc(&idr, item, i, i + 10, GFP_KERNEL) == i);
        }
        assert(idr_alloc(&idr, DUMMY_PTR, i - 2, i, GFP_KERNEL) == -ENOSPC);
        assert(idr_alloc(&idr, DUMMY_PTR, i - 2, i + 10, GFP_KERNEL) == -ENOSPC);
 
-       idr_for_each(&idr, item_idr_free, &idr);
+       idr_for_each_entry(&idr, item, id)
+               item_idr_free(id, item, &idr);
        idr_destroy(&idr);
        idr_destroy(&idr);
 
        assert(idr_is_empty(&idr));
 
        for (i = 1; i < 10000; i++) {
-               struct item *item = item_create(i, 0);
+               item = item_create(i, 0);
                assert(idr_alloc(&idr, item, 1, 20000, GFP_KERNEL) == i);
        }
 
-       idr_for_each(&idr, item_idr_free, &idr);
+       idr_for_each_entry(&idr, item, id)
+               item_idr_free(id, item, &idr);
        idr_destroy(&idr);
 
        idr_null_test();