]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Add mas_init() function
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 11 Nov 2022 20:39:16 +0000 (15:39 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 28 Nov 2022 20:18:33 +0000 (15:18 -0500)
Add a function that will zero out the maple state struct and set some
basic defaults.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
include/linux/maple_tree.h

index 554a2f38fcd3b2ac1faa1263e9f3e81f6b4cbdb6..6914fa493710242af6223b6057f08a3045c9a18b 100644 (file)
@@ -433,6 +433,7 @@ struct ma_wr_state {
                .min = 0,                                               \
                .max = ULONG_MAX,                                       \
                .alloc = NULL,                                          \
+               .mas_flags = 0,                                         \
        }
 
 #define MA_WR_STATE(name, ma_state, wr_entry)                          \
@@ -471,6 +472,16 @@ void *mas_next(struct ma_state *mas, unsigned long max);
 int mas_empty_area(struct ma_state *mas, unsigned long min, unsigned long max,
                   unsigned long size);
 
+static inline void mas_init(struct ma_state *mas, struct maple_tree *tree,
+                           unsigned long addr)
+{
+       memset(mas, 0, sizeof(struct ma_state));
+       mas->tree = tree;
+       mas->index = mas->last = addr;
+       mas->max = ULONG_MAX;
+       mas->node = MAS_START;
+}
+
 /* Checks if a mas has not found anything */
 static inline bool mas_is_none(struct ma_state *mas)
 {