git: 0fef6cb7299f - stable/14 - linuxkpi: Add `list_for_each_prev_safe()` in <linux/list.h>

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Sat, 17 Feb 2024 21:32:40 UTC
The branch stable/14 has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=0fef6cb7299f541e1b94b84d2b9a9225133b9672

commit 0fef6cb7299f541e1b94b84d2b9a9225133b9672
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2023-12-08 21:53:21 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2024-02-17 20:58:35 +0000

    linuxkpi: Add `list_for_each_prev_safe()` in <linux/list.h>
    
    [Why]
    The amdgpu DRM driver started to use it in Linux 5.18.
    
    Reviewed by:    manu
    Approved by:    manu
    Differential Revision:  https://reviews.freebsd.org/D43021
    
    (cherry picked from commit b723bcd05a991d446491e914f2b9f35e66227398)
---
 sys/compat/linuxkpi/common/include/linux/list.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/list.h b/sys/compat/linuxkpi/common/include/linux/list.h
index a27abedc55b0..ca103a670109 100644
--- a/sys/compat/linuxkpi/common/include/linux/list.h
+++ b/sys/compat/linuxkpi/common/include/linux/list.h
@@ -225,6 +225,11 @@ list_del_init(struct list_head *entry)
 
 #define	list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = (p)->prev)
 
+#define	list_for_each_prev_safe(p, n, h) 				\
+	for (p = (h)->prev, n = (p)->prev;				\
+	     p != (h);							\
+	     p = n, n = (p)->prev)
+
 #define	list_for_each_entry_from_reverse(p, h, field)	\
 	for (; &p->field != (h);			\
 	     p = list_prev_entry(p, field))