]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - lib/radix-tree.c
ENGR00331085-3: ARM: dts: imx6qdl: enable hdmi audio
[karo-tx-linux.git] / lib / radix-tree.c
index bd4a8dfdf0b8052cdaedd0b3478eea4138ac100a..7e30d2a7f346bfba9fdfc16936b583289175a241 100644 (file)
@@ -946,81 +946,6 @@ next:
 }
 EXPORT_SYMBOL(radix_tree_range_tag_if_tagged);
 
-
-/**
- *     radix_tree_next_hole    -    find the next hole (not-present entry)
- *     @root:          tree root
- *     @index:         index key
- *     @max_scan:      maximum range to search
- *
- *     Search the set [index, min(index+max_scan-1, MAX_INDEX)] for the lowest
- *     indexed hole.
- *
- *     Returns: the index of the hole if found, otherwise returns an index
- *     outside of the set specified (in which case 'return - index >= max_scan'
- *     will be true). In rare cases of index wrap-around, 0 will be returned.
- *
- *     radix_tree_next_hole may be called under rcu_read_lock. However, like
- *     radix_tree_gang_lookup, this will not atomically search a snapshot of
- *     the tree at a single point in time. For example, if a hole is created
- *     at index 5, then subsequently a hole is created at index 10,
- *     radix_tree_next_hole covering both indexes may return 10 if called
- *     under rcu_read_lock.
- */
-unsigned long radix_tree_next_hole(struct radix_tree_root *root,
-                               unsigned long index, unsigned long max_scan)
-{
-       unsigned long i;
-
-       for (i = 0; i < max_scan; i++) {
-               if (!radix_tree_lookup(root, index))
-                       break;
-               index++;
-               if (index == 0)
-                       break;
-       }
-
-       return index;
-}
-EXPORT_SYMBOL(radix_tree_next_hole);
-
-/**
- *     radix_tree_prev_hole    -    find the prev hole (not-present entry)
- *     @root:          tree root
- *     @index:         index key
- *     @max_scan:      maximum range to search
- *
- *     Search backwards in the range [max(index-max_scan+1, 0), index]
- *     for the first hole.
- *
- *     Returns: the index of the hole if found, otherwise returns an index
- *     outside of the set specified (in which case 'index - return >= max_scan'
- *     will be true). In rare cases of wrap-around, ULONG_MAX will be returned.
- *
- *     radix_tree_next_hole may be called under rcu_read_lock. However, like
- *     radix_tree_gang_lookup, this will not atomically search a snapshot of
- *     the tree at a single point in time. For example, if a hole is created
- *     at index 10, then subsequently a hole is created at index 5,
- *     radix_tree_prev_hole covering both indexes may return 5 if called under
- *     rcu_read_lock.
- */
-unsigned long radix_tree_prev_hole(struct radix_tree_root *root,
-                                  unsigned long index, unsigned long max_scan)
-{
-       unsigned long i;
-
-       for (i = 0; i < max_scan; i++) {
-               if (!radix_tree_lookup(root, index))
-                       break;
-               index--;
-               if (index == ULONG_MAX)
-                       break;
-       }
-
-       return index;
-}
-EXPORT_SYMBOL(radix_tree_prev_hole);
-
 /**
  *     radix_tree_gang_lookup - perform multiple lookup on a radix tree
  *     @root:          radix tree root
@@ -1337,15 +1262,18 @@ static inline void radix_tree_shrink(struct radix_tree_root *root)
 }
 
 /**
- *     radix_tree_delete    -    delete an item from a radix tree
+ *     radix_tree_delete_item    -    delete an item from a radix tree
  *     @root:          radix tree root
  *     @index:         index key
+ *     @item:          expected item
  *
- *     Remove the item at @index from the radix tree rooted at @root.
+ *     Remove @item at @index from the radix tree rooted at @root.
  *
- *     Returns the address of the deleted item, or NULL if it was not present.
+ *     Returns the address of the deleted item, or NULL if it was not present
+ *     or the entry at the given @index was not @item.
  */
-void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
+void *radix_tree_delete_item(struct radix_tree_root *root,
+                            unsigned long index, void *item)
 {
        struct radix_tree_node *node = NULL;
        struct radix_tree_node *slot = NULL;
@@ -1380,6 +1308,11 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
        if (slot == NULL)
                goto out;
 
+       if (item && slot != item) {
+               slot = NULL;
+               goto out;
+       }
+
        /*
         * Clear all tags associated with the item to be deleted.
         * This way of doing it would be inefficient, but seldom is any set.
@@ -1424,6 +1357,21 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
 out:
        return slot;
 }
+EXPORT_SYMBOL(radix_tree_delete_item);
+
+/**
+ *     radix_tree_delete    -    delete an item from a radix tree
+ *     @root:          radix tree root
+ *     @index:         index key
+ *
+ *     Remove the item at @index from the radix tree rooted at @root.
+ *
+ *     Returns the address of the deleted item, or NULL if it was not present.
+ */
+void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
+{
+       return radix_tree_delete_item(root, index, NULL);
+}
 EXPORT_SYMBOL(radix_tree_delete);
 
 /**