aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/llist.h6
-rw-r--r--lib/llist.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/llist.h b/include/linux/llist.h
index ca91875286bf..27bbdf5ddf82 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -142,8 +142,10 @@ static inline bool llist_empty(const struct llist_head *head)
142 * llist_add - add a new entry 142 * llist_add - add a new entry
143 * @new: new entry to be added 143 * @new: new entry to be added
144 * @head: the head for your lock-less list 144 * @head: the head for your lock-less list
145 *
146 * Return whether list is empty before adding.
145 */ 147 */
146static inline void llist_add(struct llist_node *new, struct llist_head *head) 148static inline bool llist_add(struct llist_node *new, struct llist_head *head)
147{ 149{
148 struct llist_node *entry, *old_entry; 150 struct llist_node *entry, *old_entry;
149 151
@@ -156,6 +158,8 @@ static inline void llist_add(struct llist_node *new, struct llist_head *head)
156 break; 158 break;
157 cpu_relax(); 159 cpu_relax();
158 } 160 }
161
162 return old_entry == NULL;
159} 163}
160 164
161/** 165/**
diff --git a/lib/llist.c b/lib/llist.c
index 6c69f1d14c4b..878985c4d19d 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -34,8 +34,10 @@
34 * @new_first: first entry in batch to be added 34 * @new_first: first entry in batch to be added
35 * @new_last: last entry in batch to be added 35 * @new_last: last entry in batch to be added
36 * @head: the head for your lock-less list 36 * @head: the head for your lock-less list
37 *
38 * Return whether list is empty before adding.
37 */ 39 */
38void llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, 40bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last,
39 struct llist_head *head) 41 struct llist_head *head)
40{ 42{
41 struct llist_node *entry, *old_entry; 43 struct llist_node *entry, *old_entry;
@@ -49,6 +51,8 @@ void llist_add_batch(struct llist_node *new_first, struct llist_node *new_last,
49 break; 51 break;
50 cpu_relax(); 52 cpu_relax();
51 } 53 }
54
55 return old_entry == NULL;
52} 56}
53EXPORT_SYMBOL_GPL(llist_add_batch); 57EXPORT_SYMBOL_GPL(llist_add_batch);
54 58