X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=include%2Flinux%2Flist.h;h=a02642e4710ae06d4e005f61e3f35fe1a521ad37;hb=8cf60e04a131310199d5776e2f9e915f0c468899;hp=67258b47e9ca138e7a639a0a8745dad878164b42;hpb=3d1f337b3e7378923c89f37afb573a918ef40be5;p=powerpc.git diff --git a/include/linux/list.h b/include/linux/list.h index 67258b47e9..a02642e471 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) entry->prev = LIST_POISON2; } +/** + * list_replace - replace old entry by new one + * @old : the element to be replaced + * @new : the new element to insert + * Note: if 'old' was empty, it will be overwritten. + */ +static inline void list_replace(struct list_head *old, + struct list_head *new) +{ + new->next = old->next; + new->next->prev = new; + new->prev = old->prev; + new->prev->next = new; +} + +static inline void list_replace_init(struct list_head *old, + struct list_head *new) +{ + list_replace(old, new); + INIT_LIST_HEAD(old); +} + /* * list_replace_rcu - replace old entry by new one * @old : the element to be replaced * @new : the new element to insert * * The old entry will be replaced with the new entry atomically. + * Note: 'old' should not be empty. */ static inline void list_replace_rcu(struct list_head *old, struct list_head *new) @@ -619,7 +642,7 @@ static inline void hlist_del_rcu(struct hlist_node *n) static inline void hlist_del_init(struct hlist_node *n) { - if (n->pprev) { + if (!hlist_unhashed(n)) { __hlist_del(n); INIT_HLIST_NODE(n); }