From: Matthew Wilcox (Oracle) Date: Sun, 13 Oct 2019 03:16:46 +0000 (-0400) Subject: maple_tree: Add mas_set() and mas_set_range() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=69866e41f78e58ff55e354ea2f1812b1cf139e49;p=users%2Fjedix%2Flinux-maple.git maple_tree: Add mas_set() and mas_set_range() The equivalent of xas_set() Signed-off-by: Matthew Wilcox (Oracle) --- diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index ad7f0af2794b..3219fec8965b 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -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