The last user is now gone, so remove the export of this function.
It reamins as a static function as it is used by idr_alloc(), and it's not
worth simplifying the source code since idr_alloc should be removed soon.
Also remove idr_get_next_ul() and idr_for_each_entry_ul().
Signed-off-by: Matthew Wilcox <willy@infradead.org>
- 'ide_port_for_each_present_dev'
- 'idr_for_each_entry'
- 'idr_for_each_entry_continue'
- - 'idr_for_each_entry_ul'
- 'inet_bind_bucket_for_each'
- 'inet_lhash2_for_each_icsk_rcu'
- 'key_for_each'
object with the reserved ID and finally insert the initialised object
into the IDR.
-Some users need to allocate IDs larger than ``INT_MAX``. So far all of
-these users have been content with a ``UINT_MAX`` limit, and they use
-:c:func:`idr_alloc_u32`. If you need IDs that will not fit in a u32,
-we will work with you to address your needs.
-
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
void idr_preload(gfp_t gfp_mask);
int idr_alloc(struct idr *, void *ptr, int start, int end, gfp_t);
-int __must_check idr_alloc_u32(struct idr *, void *ptr, u32 *id,
- unsigned long max, 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_get_next_ul(struct idr *, unsigned long *nextid);
void *idr_replace(struct idr *, void *, unsigned long id);
void idr_destroy(struct idr *);
#define idr_for_each_entry(idr, entry, id) \
for (id = 0; ((entry) = idr_get_next(idr, &(id))) != NULL; ++id)
-/**
- * idr_for_each_entry_ul() - Iterate over an IDR's elements of a given type.
- * @idr: IDR handle.
- * @entry: The type * to use as cursor.
- * @tmp: A temporary placeholder for ID.
- * @id: Entry ID.
- *
- * @entry and @id do not need to be initialized before the loop, and
- * after normal termination @entry is left with the value NULL. This
- * is convenient for a "not found" value.
- */
-#define idr_for_each_entry_ul(idr, entry, tmp, id) \
- for (tmp = 0, id = 0; \
- tmp <= id && ((entry) = idr_get_next_ul(idr, &(id))) != NULL; \
- tmp = id, ++id)
-
/**
* idr_for_each_entry_continue() - Continue iteration over an IDR's elements of a given type
* @idr: IDR handle.
#include <linux/spinlock.h>
#include <linux/xarray.h>
-/**
- * idr_alloc_u32() - Allocate an ID.
- * @idr: IDR handle.
- * @ptr: Pointer to be associated with the new ID.
- * @nextid: Pointer to an ID.
- * @max: The maximum ID to allocate (inclusive).
- * @gfp: Memory allocation flags.
- *
- * Allocates an unused ID in the range specified by @nextid and @max.
- * Note that @max is inclusive whereas the @end parameter to idr_alloc()
- * is exclusive. The new ID is assigned to @nextid before the pointer
- * is inserted into the IDR, so if @nextid points into the object pointed
- * to by @ptr, a concurrent lookup will not find an uninitialised ID.
- *
- * The caller should provide their own locking to ensure that two
- * concurrent modifications to the IDR are not possible. Read-only
- * accesses to the IDR may be done under the RCU read lock or may
- * exclude simultaneous writers.
- *
- * Return: 0 if an ID was allocated, -ENOMEM if memory allocation failed,
- * or -ENOSPC if no free IDs could be found. If an error occurred,
- * @nextid is unchanged.
- */
-int idr_alloc_u32(struct idr *idr, void *ptr, u32 *nextid,
+static int idr_alloc_u32(struct idr *idr, void *ptr, u32 *nextid,
unsigned long max, gfp_t gfp)
{
struct radix_tree_iter iter;
return 0;
}
-EXPORT_SYMBOL_GPL(idr_alloc_u32);
/**
* idr_alloc() - Allocate an ID.
}
EXPORT_SYMBOL(idr_get_next);
-/**
- * idr_get_next_ul() - Find next populated entry.
- * @idr: IDR handle.
- * @nextid: Pointer to an ID.
- *
- * Returns the next populated entry in the tree with an ID greater than
- * or equal to the value pointed to by @nextid. On exit, @nextid is updated
- * to the ID of the found value. To use in a loop, the value pointed to by
- * nextid must be incremented by the user.
- */
-void *idr_get_next_ul(struct idr *idr, unsigned long *nextid)
-{
- struct radix_tree_iter iter;
- void __rcu **slot;
- unsigned long base = idr->idr_base;
- unsigned long id = *nextid;
-
- id = (id < base) ? 0 : id - base;
- slot = radix_tree_iter_find(&idr->idr_rt, &iter, id);
- if (!slot)
- return NULL;
-
- *nextid = iter.index + base;
- return rcu_dereference_raw(*slot);
-}
-EXPORT_SYMBOL(idr_get_next_ul);
-
/**
* idr_replace() - replace pointer for given ID.
* @idr: IDR handle.
idr_destroy(&idr);
}
-int idr_u32_cb(int id, void *ptr, void *data)
-{
- BUG_ON(id < 0);
- BUG_ON(ptr != DUMMY_PTR);
- return 0;
-}
-
-void idr_u32_test1(struct idr *idr, u32 handle)
-{
- static bool warned = false;
- u32 id = handle;
- int sid = 0;
- void *ptr;
-
- BUG_ON(idr_alloc_u32(idr, DUMMY_PTR, &id, id, GFP_KERNEL));
- BUG_ON(id != handle);
- BUG_ON(idr_alloc_u32(idr, DUMMY_PTR, &id, id, GFP_KERNEL) != -ENOSPC);
- BUG_ON(id != handle);
- if (!warned && id > INT_MAX)
- printk("vvv Ignore these warnings\n");
- ptr = idr_get_next(idr, &sid);
- if (id > INT_MAX) {
- BUG_ON(ptr != NULL);
- BUG_ON(sid != 0);
- } else {
- BUG_ON(ptr != DUMMY_PTR);
- BUG_ON(sid != id);
- }
- idr_for_each(idr, idr_u32_cb, NULL);
- if (!warned && id > INT_MAX) {
- printk("^^^ Warnings over\n");
- warned = true;
- }
- BUG_ON(idr_remove(idr, id) != DUMMY_PTR);
- BUG_ON(!idr_is_empty(idr));
-}
-
-void idr_u32_test(int base)
-{
- DEFINE_IDR(idr);
- idr_init_base(&idr, base);
- idr_u32_test1(&idr, 10);
- idr_u32_test1(&idr, 0x7fffffff);
- idr_u32_test1(&idr, 0x80000000);
- idr_u32_test1(&idr, 0x80000001);
- idr_u32_test1(&idr, 0xffe00000);
- idr_u32_test1(&idr, 0xffffffff);
-}
-
static void idr_align_test(struct idr *idr)
{
char name[] = "Motorola 68000";
idr_get_next_test(0);
idr_get_next_test(1);
idr_get_next_test(4);
- idr_u32_test(4);
- idr_u32_test(1);
- idr_u32_test(0);
idr_align_test(&idr);
idr_find_test();
}