Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> --- lib/maple_tree.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 297d936321347..377b57bbe6b9b 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4814,7 +4814,7 @@ void *mas_next_slot(struct ma_state *mas, unsigned long max) * * Set the @mas->node to the next entry and the range_start to * the beginning value for the entry. Does not check beyond @limit. - * Sets @mas->index and @mas->last to the limit if it is hit. + * Sets @mas->index and @mas->last to the limit if it is within the limit. * Restarts on dead nodes. * * Return: the next entry or %NULL. @@ -4836,21 +4836,33 @@ static inline void *mas_next_entry(struct ma_state *mas, unsigned long limit) return mas_next_slot(mas, limit); } -static inline void *mas_prev_entry(struct ma_state *mas, unsigned long min) +/* + * mas_prev_entry() - Internal function to get the previous entry. + * @mas: The maple state + * @limit: The minimum range start. + * + * Set the @mas->node to the previous entry and the range_start to + * the beginning value for the entry. Does not check beyond @limit. + * Sets @mas->index and @mas->last to the limit if it is within the limit. + * Restarts on dead nodes. + * + * Return: the next entry or %NULL. + */ +static inline void *mas_prev_entry(struct ma_state *mas, unsigned long limit) { void *entry; - if (mas->index < min) + if (mas->index < limit) return NULL; - entry = mas_prev_slot(mas, min); + entry = mas_prev_slot(mas, limit); if (entry) return entry; if (mas_is_none(mas)) return NULL; - return mas_prev_slot(mas, min); + return mas_prev_slot(mas, limit); } /* -- 2.39.2