]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/list.h
[SPARC64]: Add of_device layer and make ebus/isa use it.
[linux-2.6-omap-h63xx.git] / include / linux / list.h
index 76f05718342c95e3abd89f0131aeeebeffe17a36..a02642e4710ae06d4e005f61e3f35fe1a521ad37 100644 (file)
@@ -197,12 +197,35 @@ static inline void list_del_rcu(struct list_head *entry)
        entry->prev = LIST_POISON2;
 }
 
+/**
+ * list_replace - replace old entry by new one
+ * @old : the element to be replaced
+ * @new : the new element to insert
+ * Note: if 'old' was empty, it will be overwritten.
+ */
+static inline void list_replace(struct list_head *old,
+                               struct list_head *new)
+{
+       new->next = old->next;
+       new->next->prev = new;
+       new->prev = old->prev;
+       new->prev->next = new;
+}
+
+static inline void list_replace_init(struct list_head *old,
+                                       struct list_head *new)
+{
+       list_replace(old, new);
+       INIT_LIST_HEAD(old);
+}
+
 /*
  * list_replace_rcu - replace old entry by new one
  * @old : the element to be replaced
  * @new : the new element to insert
  *
  * The old entry will be replaced with the new entry atomically.
+ * Note: 'old' should not be empty.
  */
 static inline void list_replace_rcu(struct list_head *old,
                                struct list_head *new)