summaryrefslogtreecommitdiff
path: root/include/linux/llist.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/llist.h')
-rw-r--r--include/linux/llist.h19
1 files changed, 7 insertions, 12 deletions
diff --git a/include/linux/llist.h b/include/linux/llist.h
index a5199f6..3e2b969 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -151,18 +151,13 @@ static inline struct llist_node *llist_next(struct llist_node *node)
*/
static inline bool llist_add(struct llist_node *new, struct llist_head *head)
{
- struct llist_node *entry, *old_entry;
-
- entry = head->first;
- for (;;) {
- old_entry = entry;
- new->next = entry;
- entry = cmpxchg(&head->first, old_entry, new);
- if (entry == old_entry)
- break;
- }
-
- return old_entry == NULL;
+ struct llist_node *first;
+
+ do {
+ new->next = first = ACCESS_ONCE(head->first);
+ } while (cmpxchg(&head->first, first, new) != first);
+
+ return !first;
}
/**