]> 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)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 18:56:23 +0000 (14:56 -0400)
The equivalent of xas_set()

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

index eb1626010935aa7cf071a0a11432dd18433cd4b9..327162a762cb8497474dd85e0e0ff38016523fae 100644 (file)
@@ -332,4 +332,36 @@ void maple_tree_init(void);
        for (entry = mt_find(mt, index, max); \
             entry; entry = mt_find_after(mt, &index, max))
 
+/*
+ * 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