Merge tag '6.1-rc6-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6
[platform/kernel/linux-starfive.git] / lib / llist.c
index 611ce48..7d78b73 100644 (file)
@@ -30,7 +30,7 @@ bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last,
 
        do {
                new_last->next = first = READ_ONCE(head->first);
-       } while (cmpxchg(&head->first, first, new_first) != first);
+       } while (!try_cmpxchg(&head->first, &first, new_first));
 
        return !first;
 }
@@ -52,18 +52,14 @@ EXPORT_SYMBOL_GPL(llist_add_batch);
  */
 struct llist_node *llist_del_first(struct llist_head *head)
 {
-       struct llist_node *entry, *old_entry, *next;
+       struct llist_node *entry, *next;
 
        entry = smp_load_acquire(&head->first);
-       for (;;) {
+       do {
                if (entry == NULL)
                        return NULL;
-               old_entry = entry;
                next = READ_ONCE(entry->next);
-               entry = cmpxchg(&head->first, old_entry, next);
-               if (entry == old_entry)
-                       break;
-       }
+       } while (!try_cmpxchg(&head->first, &entry, next));
 
        return entry;
 }