diff options
-rw-r--r-- | include/linux/list.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/list.h b/include/linux/list.h index 76f05718342c..a02642e4710a 100644 --- a/include/linux/list.h +++ b/include/linux/list.h | |||
@@ -197,12 +197,35 @@ static inline void list_del_rcu(struct list_head *entry) | |||
197 | entry->prev = LIST_POISON2; | 197 | entry->prev = LIST_POISON2; |
198 | } | 198 | } |
199 | 199 | ||
200 | /** | ||
201 | * list_replace - replace old entry by new one | ||
202 | * @old : the element to be replaced | ||
203 | * @new : the new element to insert | ||
204 | * Note: if 'old' was empty, it will be overwritten. | ||
205 | */ | ||
206 | static inline void list_replace(struct list_head *old, | ||
207 | struct list_head *new) | ||
208 | { | ||
209 | new->next = old->next; | ||
210 | new->next->prev = new; | ||
211 | new->prev = old->prev; | ||
212 | new->prev->next = new; | ||
213 | } | ||
214 | |||
215 | static inline void list_replace_init(struct list_head *old, | ||
216 | struct list_head *new) | ||
217 | { | ||
218 | list_replace(old, new); | ||
219 | INIT_LIST_HEAD(old); | ||
220 | } | ||
221 | |||
200 | /* | 222 | /* |
201 | * list_replace_rcu - replace old entry by new one | 223 | * list_replace_rcu - replace old entry by new one |
202 | * @old : the element to be replaced | 224 | * @old : the element to be replaced |
203 | * @new : the new element to insert | 225 | * @new : the new element to insert |
204 | * | 226 | * |
205 | * The old entry will be replaced with the new entry atomically. | 227 | * The old entry will be replaced with the new entry atomically. |
228 | * Note: 'old' should not be empty. | ||
206 | */ | 229 | */ |
207 | static inline void list_replace_rcu(struct list_head *old, | 230 | static inline void list_replace_rcu(struct list_head *old, |
208 | struct list_head *new) | 231 | struct list_head *new) |