[Skiboot] [PATCH 1/2] list: Add list_add_after()

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Tue Feb 25 22:13:27 AEDT 2020


Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 ccan/list/list.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/ccan/list/list.h b/ccan/list/list.h
index fdeddeb4d..1d75dd92a 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -183,6 +183,25 @@ static inline void list_add_before(struct list_head *h, struct list_node *n,
 		(void)list_debug(h);
 }
 
+/**
+ * list_add_after - add an entry after another entry.
+ * @h: the list_head to add the node to (we use it for debug purposes, can be NULL)
+ * @n: the list_node to add to the list.
+ * @p: the list_node of the other entry
+ *
+ * The list_node does not need to be initialized; it will be overwritten.
+ */
+static inline void list_add_after(struct list_head *h, struct list_node *n,
+				  struct list_node *p)
+{
+	n->next = p->next;
+	n->prev = p;
+	p->next = n;
+	n->next->prev = n;
+	if (h)
+		(void)list_debug(h);
+}
+
 /**
  * list_add_tail - add an entry at the end of a linked list.
  * @h: the list_head to add the node to
-- 
2.21.1



More information about the Skiboot mailing list