]>
Commit | Line | Data |
---|---|---|
199a9afc DJ |
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 | ||
8bc3bcc9 | 9 | #include <linux/export.h> |
199a9afc | 10 | #include <linux/list.h> |
50af5ead | 11 | #include <linux/bug.h> |
b116ee4d | 12 | #include <linux/kernel.h> |
199a9afc DJ |
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 | ||
21 | void __list_add(struct list_head *new, | |
22 | struct list_head *prev, | |
23 | struct list_head *next) | |
24 | { | |
924d9add DJ |
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); | |
199a9afc DJ |
33 | next->prev = new; |
34 | new->next = next; | |
35 | new->prev = prev; | |
36 | prev->next = new; | |
37 | } | |
38 | EXPORT_SYMBOL(__list_add); | |
39 | ||
3c18d4de LT |
40 | void __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 | } | |
63 | EXPORT_SYMBOL(__list_del_entry); | |
64 | ||
199a9afc DJ |
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 | */ | |
71 | void list_del(struct list_head *entry) | |
72 | { | |
3c18d4de | 73 | __list_del_entry(entry); |
199a9afc DJ |
74 | entry->next = LIST_POISON1; |
75 | entry->prev = LIST_POISON2; | |
76 | } | |
77 | EXPORT_SYMBOL(list_del); |