Add list_prev_entry, list_next_entry
authorGeoff Levand <geoff@infradead.org>
Sat, 12 Nov 2011 06:52:05 +0000 (22:52 -0800)
committerGeoff Levand <geoff@infradead.org>
Sat, 12 Nov 2011 06:52:05 +0000 (22:52 -0800)
Signed-off-by: Geoff Levand <geoff@infradead.org>
lib/list/list.h

index d93f8a88021183a25ca3b4c35e8accca664b469b..7f9955f93115e2761fbe1b0ec94398480d40e8a8 100644 (file)
@@ -27,14 +27,19 @@ struct list {
        ? NULL \
        : container_of(_ptr, _type, _member))
 
+#define list_prev_entry(_list, _pos, _member) \
+       list_entry(_pos->_member.prev, typeof(*_pos), _member, _list)
+
+#define list_next_entry(_list, _pos, _member) \
+       list_entry(_pos->_member.next, typeof(*_pos), _member, _list)
+
 #define list_for_each_entry(_list, _pos, _member) \
        for (_pos = list_entry((_list)->head.next, typeof(*_pos), _member, _list); \
-               _pos; \
-               _pos = list_entry(_pos->_member.next, typeof(*_pos), _member, _list))
+               _pos; _pos = list_next_entry(_list, _pos, _member))
 
 #define list_for_each_entry_continue(_list, _pos, _member) \
-       for (; _pos; \
-               _pos = list_entry(_pos->_member.next, typeof(*_pos), _member, _list))
+       for (; _pos; _pos = list_next_entry(_list, _pos, _member))
+
 
 #define STATIC_LIST(_list) static struct list _list = { \
        .head = { \