at v3.4 2.0 kB view raw
1/* 2 * Copyright 2006, Red Hat, Inc., Dave Jones 3 * Released under the General Public License (GPL). 4 * 5 * This file contains the linked list implementations for 6 * DEBUG_LIST. 7 */ 8 9#include <linux/export.h> 10#include <linux/list.h> 11#include <linux/bug.h> 12#include <linux/kernel.h> 13 14/* 15 * Insert a new entry between two known consecutive entries. 16 * 17 * This is only for internal list manipulation where we know 18 * the prev/next entries already! 19 */ 20 21void __list_add(struct list_head *new, 22 struct list_head *prev, 23 struct list_head *next) 24{ 25 WARN(next->prev != prev, 26 "list_add corruption. next->prev should be " 27 "prev (%p), but was %p. (next=%p).\n", 28 prev, next->prev, next); 29 WARN(prev->next != next, 30 "list_add corruption. prev->next should be " 31 "next (%p), but was %p. (prev=%p).\n", 32 next, prev->next, prev); 33 next->prev = new; 34 new->next = next; 35 new->prev = prev; 36 prev->next = new; 37} 38EXPORT_SYMBOL(__list_add); 39 40void __list_del_entry(struct list_head *entry) 41{ 42 struct list_head *prev, *next; 43 44 prev = entry->prev; 45 next = entry->next; 46 47 if (WARN(next == LIST_POISON1, 48 "list_del corruption, %p->next is LIST_POISON1 (%p)\n", 49 entry, LIST_POISON1) || 50 WARN(prev == LIST_POISON2, 51 "list_del corruption, %p->prev is LIST_POISON2 (%p)\n", 52 entry, LIST_POISON2) || 53 WARN(prev->next != entry, 54 "list_del corruption. prev->next should be %p, " 55 "but was %p\n", entry, prev->next) || 56 WARN(next->prev != entry, 57 "list_del corruption. next->prev should be %p, " 58 "but was %p\n", entry, next->prev)) 59 return; 60 61 __list_del(prev, next); 62} 63EXPORT_SYMBOL(__list_del_entry); 64 65/** 66 * list_del - deletes entry from list. 67 * @entry: the element to delete from the list. 68 * Note: list_empty on entry does not return true after this, the entry is 69 * in an undefined state. 70 */ 71void list_del(struct list_head *entry) 72{ 73 __list_del_entry(entry); 74 entry->next = LIST_POISON1; 75 entry->prev = LIST_POISON2; 76} 77EXPORT_SYMBOL(list_del);