]> www.infradead.org Git - users/willy/xarray.git/commitdiff
idr: Remove idr_alloc_u32
authorMatthew Wilcox <willy@infradead.org>
Sun, 10 Feb 2019 04:14:03 +0000 (23:14 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 9 Aug 2019 01:38:15 +0000 (21:38 -0400)
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>
.clang-format
Documentation/core-api/idr.rst
include/linux/idr.h
lib/idr.c
tools/testing/radix-tree/idr-test.c

index 8a3e01961e9579ee281e2f727c6dd20570630e06..c43b016d03bd458494d3e2cc5382a35236822557 100644 (file)
@@ -302,7 +302,6 @@ ForEachMacros:
   - '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'
index 03f69b588c15fc99d5f5f9352522ce5d31e159d0..17ea87017c7857e6408244a2b563fa55122880fd 100644 (file)
@@ -34,11 +34,6 @@ ID by passing a ``NULL`` pointer to the allocation function; initialise the
 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
index cff0201994d0dd4f3b7393b8aec16e82fa216092..b4ede7075f93baea0d9192ffc92c150b74f48053 100644 (file)
@@ -84,14 +84,11 @@ struct idr {
 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 *);
 
@@ -157,22 +154,6 @@ static inline void idr_preload_end(void)
 #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.
index 3f81aebf1e1edef64d19501fbbc004dcdd531493..190834dab4092cd0b50bbfeacd1b78a67b7a0e07 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -7,30 +7,7 @@
 #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;
@@ -54,7 +31,6 @@ int idr_alloc_u32(struct idr *idr, void *ptr, u32 *nextid,
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(idr_alloc_u32);
 
 /**
  * idr_alloc() - Allocate an ID.
@@ -212,33 +188,6 @@ void *idr_get_next(struct idr *idr, int *nextid)
 }
 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.
index c0432f96f62ba6e85438ada0a920b75053777ba9..9deb441fa9e348ba8cada82cb8ee37330fb8ddf2 100644 (file)
@@ -143,55 +143,6 @@ void idr_get_next_test(int base)
        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";
@@ -356,9 +307,6 @@ void idr_checks(void)
        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();
 }