hlist: Add hlist_is_singular_node() helper
authorThomas Gleixner <[email protected]>
Mon, 4 Jul 2016 09:50:27 +0000 (09:50 +0000)
committerIngo Molnar <[email protected]>
Thu, 7 Jul 2016 08:35:07 +0000 (10:35 +0200)
Required to figure out whether the entry is the only one in the hlist.

Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Frederic Weisbecker <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Cc: Chris Mason <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: George Spelvin <[email protected]>
Cc: Josh Triplett <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
include/linux/list.h

index 5356f4d661a721ba0446b1183e2a834f3bf3b56f..5183138aa932da88c83177b9f8372bd9c3437e13 100644 (file)
@@ -678,6 +678,16 @@ static inline bool hlist_fake(struct hlist_node *h)
        return h->pprev == &h->next;
 }
 
+/*
+ * Check whether the node is the only node of the head without
+ * accessing head:
+ */
+static inline bool
+hlist_is_singular_node(struct hlist_node *n, struct hlist_head *h)
+{
+       return !n->next && n->pprev == &h->first;
+}
+
 /*
  * Move a list from one list head to another. Fixup the pprev
  * reference of the first entry if it exists.