@@ -127,6 +127,36 @@ static inline void list_del(struct list_head *entry)
127
127
entry -> prev = LIST_POISON2 ;
128
128
}
129
129
130
+ /**
131
+ * list_replace - replace old entry by new one
132
+ * @old : the element to be replaced
133
+ * @new : the new element to insert
134
+ *
135
+ * If @old was empty, it will be overwritten.
136
+ */
137
+ static inline void list_replace (struct list_head * old ,
138
+ struct list_head * new )
139
+ {
140
+ new -> next = old -> next ;
141
+ new -> next -> prev = new ;
142
+ new -> prev = old -> prev ;
143
+ new -> prev -> next = new ;
144
+ }
145
+
146
+ /**
147
+ * list_replace_init - replace old entry by new one and initialize the old one
148
+ * @old : the element to be replaced
149
+ * @new : the new element to insert
150
+ *
151
+ * If @old was empty, it will be overwritten.
152
+ */
153
+ static inline void list_replace_init (struct list_head * old ,
154
+ struct list_head * new )
155
+ {
156
+ list_replace (old , new );
157
+ INIT_LIST_HEAD (old );
158
+ }
159
+
130
160
/**
131
161
* list_move - delete from one list and add as another's head
132
162
* @list: the entry to move
@@ -150,6 +180,26 @@ static inline void list_move_tail(struct list_head *list,
150
180
list_add_tail (list , head );
151
181
}
152
182
183
+ /**
184
+ * list_is_first -- tests whether @list is the first entry in list @head
185
+ * @list: the entry to test
186
+ * @head: the head of the list
187
+ */
188
+ static inline int list_is_first (const struct list_head * list , const struct list_head * head )
189
+ {
190
+ return list -> prev == head ;
191
+ }
192
+
193
+ /**
194
+ * list_is_last - tests whether @list is the last entry in list @head
195
+ * @list: the entry to test
196
+ * @head: the head of the list
197
+ */
198
+ static inline int list_is_last (const struct list_head * list , const struct list_head * head )
199
+ {
200
+ return list -> next == head ;
201
+ }
202
+
153
203
/**
154
204
* list_is_head - tests whether @list is the list @head
155
205
* @list: the entry to test
0 commit comments