From: Matthew Wilcox Date: Fri, 15 Feb 2019 19:54:00 +0000 (-0500) Subject: Remove idr_for_each() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=edfd903f77982a97daedbfb278e7a4deff546367;p=users%2Fwilly%2Fxarray.git Remove idr_for_each() With no more users remaining, delete the function. Signed-off-by: Matthew Wilcox --- diff --git a/Documentation/core-api/idr.rst b/Documentation/core-api/idr.rst index e81e48909e31..a04a2d5f22d3 100644 --- a/Documentation/core-api/idr.rst +++ b/Documentation/core-api/idr.rst @@ -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. diff --git a/include/linux/idr.h b/include/linux/idr.h index e805371dd1b2..6e556350857a 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h @@ -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 *); diff --git a/lib/idr.c b/lib/idr.c index b11ee953ac28..0182590cc5f7 100644 --- 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. diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 4a7369612db4..60d92ffd057c 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -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) diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c index ce97e50e8f0f..a62114f74b81 100644 --- a/tools/testing/radix-tree/idr-test.c +++ b/tools/testing/radix-tree/idr-test.c @@ -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();