@@ -127,6 +127,29 @@ static inline void list_del(struct list_head *entry)
127
127
entry -> prev = LIST_POISON2 ;
128
128
}
129
129
130
+ /**
131
+ * list_move - delete from one list and add as another's head
132
+ * @list: the entry to move
133
+ * @head: the head that will precede our entry
134
+ */
135
+ static inline void list_move (struct list_head * list , struct list_head * head )
136
+ {
137
+ __list_del_entry (list );
138
+ list_add (list , head );
139
+ }
140
+
141
+ /**
142
+ * list_move_tail - delete from one list and add as another's tail
143
+ * @list: the entry to move
144
+ * @head: the head that will follow our entry
145
+ */
146
+ static inline void list_move_tail (struct list_head * list ,
147
+ struct list_head * head )
148
+ {
149
+ __list_del_entry (list );
150
+ list_add_tail (list , head );
151
+ }
152
+
130
153
/**
131
154
* list_is_head - tests whether @list is the list @head
132
155
* @list: the entry to test
@@ -166,6 +189,17 @@ static inline int list_empty(const struct list_head *head)
166
189
#define list_first_entry (ptr , type , member ) \
167
190
list_entry((ptr)->next, type, member)
168
191
192
+ /**
193
+ * list_last_entry - get the last element from a list
194
+ * @ptr: the list head to take the element from.
195
+ * @type: the type of the struct this is embedded in.
196
+ * @member: the name of the list_head within the struct.
197
+ *
198
+ * Note, that list is expected to be not empty.
199
+ */
200
+ #define list_last_entry (ptr , type , member ) \
201
+ list_entry((ptr)->prev, type, member)
202
+
169
203
/**
170
204
* list_next_entry - get the next element in list
171
205
* @pos: the type * to cursor
@@ -174,6 +208,14 @@ static inline int list_empty(const struct list_head *head)
174
208
#define list_next_entry (pos , member ) \
175
209
list_entry((pos)->member.next, typeof(*(pos)), member)
176
210
211
+ /**
212
+ * list_prev_entry - get the prev element in list
213
+ * @pos: the type * to cursor
214
+ * @member: the name of the list_head within the struct.
215
+ */
216
+ #define list_prev_entry (pos , member ) \
217
+ list_entry((pos)->member.prev, typeof(*(pos)), member)
218
+
177
219
/**
178
220
* list_entry_is_head - test if the entry points to the head of the list
179
221
* @pos: the type * to cursor
@@ -194,6 +236,17 @@ static inline int list_empty(const struct list_head *head)
194
236
!list_entry_is_head(pos, head, member); \
195
237
pos = list_next_entry(pos, member))
196
238
239
+ /**
240
+ * list_for_each_entry_reverse - iterate backwards over list of given type.
241
+ * @pos: the type * to use as a loop cursor.
242
+ * @head: the head for your list.
243
+ * @member: the name of the list_head within the struct.
244
+ */
245
+ #define list_for_each_entry_reverse (pos , head , member ) \
246
+ for (pos = list_last_entry(head, typeof(*pos), member); \
247
+ !list_entry_is_head(pos, head, member); \
248
+ pos = list_prev_entry(pos, member))
249
+
197
250
/**
198
251
* list_for_each_entry_safe - iterate over list of given type. Safe against removal of list entry
199
252
* @pos: the type * to use as a loop cursor.
0 commit comments