diff options
author | Ingo Molnar <mingo@kernel.org> | 2023-09-21 11:32:58 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2023-09-22 09:38:42 +0200 |
commit | 8bf0cdfac7f8aa3fa6151b5c5f5eebdb44a64e89 (patch) | |
tree | 05ef70b4de7409fae497466155c53625ee42d0ef | |
parent | 1632d47fae2f2d229dd432854c4443ebb0bb27a4 (diff) | |
download | linux-8bf0cdfac7f8aa3fa6151b5c5f5eebdb44a64e89.tar.gz linux-8bf0cdfac7f8aa3fa6151b5c5f5eebdb44a64e89.tar.bz2 linux-8bf0cdfac7f8aa3fa6151b5c5f5eebdb44a64e89.zip |
<linux/list.h>: Introduce the list_for_each_reverse() method
The list_head counterpart of list_for_each_entry_reverse() was missing,
add it to complete the list handling APIs in <linux/list.h>.
[ This new API is also relied on by a WIP scheduler patch, so this
variant is not a theoretical possibility only. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
-rw-r--r-- | include/linux/list.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/list.h b/include/linux/list.h index 164b4d0e9d2a..1837caedf723 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -687,6 +687,14 @@ static inline void list_splice_tail_init(struct list_head *list, for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) /** + * list_for_each_reverse - iterate backwards over a list + * @pos: the &struct list_head to use as a loop cursor. + * @head: the head for your list. + */ +#define list_for_each_reverse(pos, head) \ + for (pos = (head)->prev; pos != (head); pos = pos->prev) + +/** * list_for_each_rcu - Iterate over a list in an RCU-safe fashion * @pos: the &struct list_head to use as a loop cursor. * @head: the head for your list. |