Similar to list_first_entry, this macro allows to retrieve the list's
last entry.

Signed-off-by: Phil Sutter <[email protected]>
---
 include/list.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/list.h b/include/list.h
index 75d2921240101..5405dbbc0066b 100644
--- a/include/list.h
+++ b/include/list.h
@@ -337,6 +337,17 @@ static inline void list_splice_tail_init(struct list_head 
*list,
 #define list_first_entry(ptr, type, member) \
        list_entry((ptr)->next, type, member)
 
+/**
+ * list_last_entry - get the last element from a list
+ * @ptr:       the list head to take the element from.
+ * @type:      the type of the struct this is embedded in.
+ * @member:    the name of the list_struct within the struct.
+ *
+ * Note, that list is expected to be not empty.
+ */
+#define list_last_entry(ptr, type, member) \
+       list_entry((ptr)->prev, type, member)
+
 
 /**
  * list_for_each_entry -       iterate over list of given type
-- 
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to