]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Fix compile warnings
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 28 Feb 2022 14:58:21 +0000 (09:58 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 8 Mar 2022 18:19:15 +0000 (13:19 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
include/linux/maple_tree.h
lib/maple_tree.c

index e808794e06a5800e46c1173febb5ed3a48c177b4..9737e5ca9d26a61f2f9866837b6784914a146be8 100644 (file)
@@ -316,6 +316,12 @@ int mtree_insert(struct maple_tree *mt, unsigned long index,
                void *entry, gfp_t gfp);
 int mtree_insert_range(struct maple_tree *mt, unsigned long first,
                unsigned long last, void *entry, gfp_t gfp);
+int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp,
+               void *entry, unsigned long size, unsigned long min,
+               unsigned long max, gfp_t gfp);
+int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp,
+               void *entry, unsigned long size, unsigned long min,
+               unsigned long max, gfp_t gfp);
 
 int mtree_store_range(struct maple_tree *mt, unsigned long first,
                      unsigned long last, void *entry, gfp_t gfp);
index d782e747771b74b8a87b4da83bada8531443c7b2..a7737fe7f1e07ab7e1838f00d5e5a94539aae092 100644 (file)
@@ -464,16 +464,19 @@ void mte_set_parent(struct maple_enode *enode, const struct maple_enode *parent,
        unsigned long type;
        enum maple_type p_type = mte_node_type(parent);
 
+       BUG_ON(p_type == maple_dense);
+       BUG_ON(p_type == maple_leaf_64);
+
        switch(p_type) {
        case maple_range_64:
        case maple_arange_64:
                shift = MAPLE_PARENT_SLOT_SHIFT;
                type = MAPLE_PARENT_RANGE64;
                break;
+       default:
        case maple_dense:
        case maple_leaf_64:
                shift = type = 0;
-               BUG_ON(1);
                break;
        }
 
@@ -828,20 +831,6 @@ static inline void *mas_slot(struct ma_state *mas, void __rcu **slots,
        return mt_slot(mas->tree, slots, offset);
 }
 
-/*
- * mas_get_slot() - Get the entry in the maple state node stored at @offset.
- * @mas: The maple state
- * @offset: The offset into the slot array to fetch.
- *
- * Return: The entry stored at @offset.
- */
-static inline struct maple_enode *mas_get_slot(struct ma_state *mas,
-               unsigned char offset)
-{
-       return mas_slot(mas, ma_slots(mas_mn(mas), mte_node_type(mas->node)),
-                      offset);
-}
-
 /*
  * mas_root() - Get the maple tree root.
  * @mas: The maple state.
@@ -4585,93 +4574,6 @@ retry:
 
 }
 
-/*
- * mas_dead_node() - Check if the maple state is pointing to a dead node.
- * @mas: The maple state
- * @index: The index to restore in @mas.
- *
- * Return: 1 if @mas has been reset to MAS_START, 0 otherwise.
- */
-static inline int mas_dead_node(struct ma_state *mas, unsigned long index)
-{
-       if (unlikely(!mas_searchable(mas) || mas_is_start(mas)))
-               return 0;
-
-       if (likely(!mte_dead_node(mas->node)))
-               return 0;
-
-       mas_rewalk(mas, index);
-       return 1;
-}
-
-/*
- * mas_first_entry() - Go the first leaf and find the first entry.
- * @mas: the maple state.
- * @limit: the maximum index to check.
- * @*r_start: Pointer to set to the range start.
- *
- * Sets mas->offset to the offset of the entry, r_start to the range minimum.
- *
- * Return: The first entry or MAS_NONE.
- */
-static inline void *mas_first_entry(struct ma_state *mas, struct maple_node *mn,
-               unsigned long limit, enum maple_type mt)
-{
-       unsigned long max;
-       unsigned long *pivots;
-       void __rcu **slots;
-       void *entry = NULL;
-
-       mas->index = mas->min;
-       if (mas->index > limit)
-               goto none;
-
-       max = mas->max;
-       mas->offset = 0;
-       while (likely(!ma_is_leaf(mt))) {
-               slots = ma_slots(mn, mt);
-               pivots = ma_pivots(mn, mt);
-               max = pivots[0];
-               entry = mas_slot(mas, slots, 0);
-               if (unlikely(ma_dead_node(mn)))
-                       return NULL;
-               mas->node = entry;
-               mn = mas_mn(mas);
-               mt = mte_node_type(mas->node);
-       }
-
-       mas->max = max;
-       slots = ma_slots(mn, mt);
-       entry = mas_slot(mas, slots, 0);
-       if (unlikely(ma_dead_node(mn)))
-               return NULL;
-
-       /* Slot 0 or 1 must be set */
-       if (mas->index > limit)
-               goto none;
-
-       if(likely(entry))
-               return entry;
-
-       pivots = ma_pivots(mn, mt);
-       mas->index = pivots[0] + 1;
-       mas->offset = 1;
-       entry = mas_slot(mas, slots, 1);
-       if (unlikely(ma_dead_node(mn)))
-               return NULL;
-
-       if (mas->index > limit)
-               goto none;
-
-       if(likely(entry))
-               return entry;
-
-none:
-       if (likely(!ma_dead_node(mn)))
-               mas->node = MAS_NONE;
-       return NULL;
-}
-
 /*
  * mas_next_entry() - Internal function to get the next entry.
  * @mas: The maple state
@@ -5543,7 +5445,7 @@ static inline void mte_destroy_walk(struct maple_enode *enode,
        }
 }
 
-void mas_wr_store_setup(struct ma_wr_state *wr_mas)
+static void mas_wr_store_setup(struct ma_wr_state *wr_mas)
 {
        if (!mas_is_start(wr_mas->mas)) {
                if (mas_is_none(wr_mas->mas))
@@ -6205,6 +6107,7 @@ retry:
        mtree_unlock(mt);
        return ret;
 }
+EXPORT_SYMBOL(mtree_alloc_range);
 
 int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp,
                void *entry, unsigned long size, unsigned long min,
@@ -6237,6 +6140,7 @@ retry:
        mtree_unlock(mt);
        return ret;
 }
+EXPORT_SYMBOL(mtree_alloc_rrange);
 
 /**
  * mtree_erase() - Find an index and erase the entire range.
@@ -6476,8 +6380,76 @@ static void mas_bfs_preorder(struct ma_state *mas)
 
 }
 #endif /* CONFIG_MAPLE_EXTRAS */
+#endif /* CONFIG_MAPLE_SEARCH */
 
-#endif
+/*
+ * mas_first_entry() - Go the first leaf and find the first entry.
+ * @mas: the maple state.
+ * @limit: the maximum index to check.
+ * @*r_start: Pointer to set to the range start.
+ *
+ * Sets mas->offset to the offset of the entry, r_start to the range minimum.
+ *
+ * Return: The first entry or MAS_NONE.
+ */
+static inline void *mas_first_entry(struct ma_state *mas, struct maple_node *mn,
+               unsigned long limit, enum maple_type mt)
+
+{
+       unsigned long max;
+       unsigned long *pivots;
+       void __rcu **slots;
+       void *entry = NULL;
+
+       mas->index = mas->min;
+       if (mas->index > limit)
+               goto none;
+
+       max = mas->max;
+       mas->offset = 0;
+       while (likely(!ma_is_leaf(mt))) {
+               slots = ma_slots(mn, mt);
+               pivots = ma_pivots(mn, mt);
+               max = pivots[0];
+               entry = mas_slot(mas, slots, 0);
+               if (unlikely(ma_dead_node(mn)))
+                       return NULL;
+               mas->node = entry;
+               mn = mas_mn(mas);
+               mt = mte_node_type(mas->node);
+       }
+
+       mas->max = max;
+       slots = ma_slots(mn, mt);
+       entry = mas_slot(mas, slots, 0);
+       if (unlikely(ma_dead_node(mn)))
+               return NULL;
+
+       /* Slot 0 or 1 must be set */
+       if (mas->index > limit)
+               goto none;
+
+       if(likely(entry))
+               return entry;
+
+       pivots = ma_pivots(mn, mt);
+       mas->index = pivots[0] + 1;
+       mas->offset = 1;
+       entry = mas_slot(mas, slots, 1);
+       if (unlikely(ma_dead_node(mn)))
+               return NULL;
+
+       if (mas->index > limit)
+               goto none;
+
+       if(likely(entry))
+               return entry;
+
+none:
+       if (likely(!ma_dead_node(mn)))
+               mas->node = MAS_NONE;
+       return NULL;
+}
 
 /* Depth first search, post-order */
 static void mas_dfs_postorder(struct ma_state *mas, unsigned long max)
@@ -6666,6 +6638,20 @@ void mt_dump(const struct maple_tree *mt)
                mt_dump_node(mt, entry, 0, mt_max[mte_node_type(entry)], 0);
 }
 
+/*
+ * mas_get_slot() - Get the entry in the maple state node stored at @offset.
+ * @mas: The maple state
+ * @offset: The offset into the slot array to fetch.
+ *
+ * Return: The entry stored at @offset.
+ */
+static inline struct maple_enode *mas_get_slot(struct ma_state *mas,
+               unsigned char offset)
+{
+       return mas_slot(mas, ma_slots(mas_mn(mas), mte_node_type(mas->node)),
+                      offset);
+}
+
 /*
  * Calculate the maximum gap in a node and check if that's what is reported in
  * the parent (unless root).