]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
llist: return whether list is empty before adding in llist_add
authorHuang Ying <ying.huang@intel.com>
Wed, 28 Sep 2011 00:50:48 +0000 (10:50 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 30 Sep 2011 04:53:41 +0000 (14:53 +1000)
This is needed by irq_work.  And because list_add_xxx functions are
inline, this can be optimized out if not needed by callers.

Signed-off-by: Huang Ying <ying.huang@intel.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <>
include/linux/llist.h

index 32510931b23b92ed3913e6f1392810d8ff353cb3..48f49e91bf2e41dbfb99bff0870f16b434caa314 100644 (file)
@@ -148,8 +148,10 @@ static inline bool llist_empty(const struct llist_head *head)
  * llist_add - add a new entry
  * @new:       new entry to be added
  * @head:      the head for your lock-less list
+ *
+ * Return whether list is empty before adding.
  */
-static inline void llist_add(struct llist_node *new, struct llist_head *head)
+static inline bool llist_add(struct llist_node *new, struct llist_head *head)
 {
        struct llist_node *entry, *old_entry;
 
@@ -164,6 +166,8 @@ static inline void llist_add(struct llist_node *new, struct llist_head *head)
                        break;
                cpu_relax();
        }
+
+       return old_entry == NULL;
 }
 
 /**
@@ -171,8 +175,10 @@ static inline void llist_add(struct llist_node *new, struct llist_head *head)
  * @new_first: first entry in batch to be added
  * @new_last:  last entry in batch to be added
  * @head:      the head for your lock-less list
+ *
+ * Return whether list is empty before adding.
  */
-static inline void llist_add_batch(struct llist_node *new_first,
+static inline bool llist_add_batch(struct llist_node *new_first,
                                   struct llist_node *new_last,
                                   struct llist_head *head)
 {
@@ -189,6 +195,8 @@ static inline void llist_add_batch(struct llist_node *new_first,
                        break;
                cpu_relax();
        }
+
+       return old_entry == NULL;
 }
 
 /**