diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2011-12-07 09:28:30 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-02-15 08:21:34 +0100 |
commit | c9c5440e616988d8fdd3056696ab1552825d78bd (patch) | |
tree | 348e01dcc6fe538a0fa921492d1cb4aaa805923c /include | |
parent | 4b06ebc820aa9a46dfb73c7050b073d8224b4b70 (diff) | |
download | barebox-c9c5440e616988d8fdd3056696ab1552825d78bd.tar.gz barebox-c9c5440e616988d8fdd3056696ab1552825d78bd.tar.xz |
list: add list_last_entry function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | 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 1a4cbc49a2..15ed499cae 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. |