[PATCH 1/3] list: add list_last_entry function

Sascha Hauer s.hauer at pengutronix.de
Wed Feb 15 03:10:48 EST 2012


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 include/linux/list.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/linux/list.h b/include/linux/list.h
index 1a4cbc4..15ed499 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -272,6 +272,17 @@ static inline void list_splice_init(struct list_head *list,
 	list_entry((ptr)->next, type, member)
 
 /**
+ * list_last_entry - get the last element from a list
+ * @head: 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(head, type, member) \
+	list_entry((head)->prev, type, member)
+
+/**
  * list_for_each	-	iterate over a list
  * @pos:	the &struct list_head to use as a loop cursor.
  * @head:	the head for your list.
-- 
1.7.9




More information about the barebox mailing list