diff options
Diffstat (limited to 'include/list.h')
-rw-r--r-- | include/list.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/list.h b/include/list.h index 857921e3..4382a670 100644 --- a/include/list.h +++ b/include/list.h @@ -349,6 +349,25 @@ static inline void list_splice_tail_init(struct list_head *list, list_entry((ptr)->next, type, member) /** + * list_prev_entry - get the prev element in list + * @ptr: the type * to cursor + * @member: the name of the list_head within the struct. + */ +#define list_prev_entry(ptr, member) \ + list_entry((ptr)->member.prev, typeof(*(ptr)), 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_head 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_next_entry - get the next element in list * @pos: the type * to cursor * @member: the name of the list_head within the struct. |