]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Add mas_set() and mas_set_range()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sun, 13 Oct 2019 03:16:46 +0000 (23:16 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Sun, 13 Oct 2019 03:26:30 +0000 (23:26 -0400)
The equivalent of xas_set()

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/maple_tree.h

index ad7f0af2794bc7e328077433e5e3e348fc59c534..3219fec8965b13075264f5ce83101342febb96b6 100644 (file)
@@ -303,4 +303,37 @@ void *mas_find(struct ma_state *mas, unsigned long max);
 bool mas_nomem(struct ma_state *mas, gfp_t gfp);
 void mas_pause(struct ma_state *mas);
 void maple_tree_init(void);
+
+/**
+ * mas_set_range() - Set up Maple Tree operation state for a different index.
+ * @xas: Maple Tree operation state.
+ * @start: New start of range in the Maple Tree.
+ * @last: New end of range in the Maple Tree.
+ *
+ * Move the operation state to refer to a different range.  This will
+ * have the effect of starting a walk from the top; see mas_next()
+ * to move to an adjacent index.
+ */
+static inline void mas_set_range(struct ma_state *mas, unsigned long start,
+               unsigned long last)
+{
+       mas->index = start;
+       mas->last = last;
+       mas->node = MAS_START;
+}
+
+/**
+ * mas_set() - Set up Maple Tree operation state for a different index.
+ * @xas: Maple Tree operation state.
+ * @index: New index into the Maple Tree.
+ *
+ * Move the operation state to refer to a different index.  This will
+ * have the effect of starting a walk from the top; see mas_next()
+ * to move to an adjacent index.
+ */
+static inline void mas_set(struct ma_state *mas, unsigned long index)
+{
+       mas_set_range(mas, index, index);
+}
+
 #endif