]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - lib/list_debug.c
lib: fix implicit users of kernel.h for TAINT_WARN
[mirror_ubuntu-artful-kernel.git] / lib / list_debug.c
CommitLineData
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
9#include <linux/module.h>
10#include <linux/list.h>
b116ee4d 11#include <linux/kernel.h>
199a9afc
DJ
12
13/*
14 * Insert a new entry between two known consecutive entries.
15 *
16 * This is only for internal list manipulation where we know
17 * the prev/next entries already!
18 */
19
20void __list_add(struct list_head *new,
21 struct list_head *prev,
22 struct list_head *next)
23{
924d9add
DJ
24 WARN(next->prev != prev,
25 "list_add corruption. next->prev should be "
26 "prev (%p), but was %p. (next=%p).\n",
27 prev, next->prev, next);
28 WARN(prev->next != next,
29 "list_add corruption. prev->next should be "
30 "next (%p), but was %p. (prev=%p).\n",
31 next, prev->next, prev);
199a9afc
DJ
32 next->prev = new;
33 new->next = next;
34 new->prev = prev;
35 prev->next = new;
36}
37EXPORT_SYMBOL(__list_add);
38
3c18d4de
LT
39void __list_del_entry(struct list_head *entry)
40{
41 struct list_head *prev, *next;
42
43 prev = entry->prev;
44 next = entry->next;
45
46 if (WARN(next == LIST_POISON1,
47 "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
48 entry, LIST_POISON1) ||
49 WARN(prev == LIST_POISON2,
50 "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
51 entry, LIST_POISON2) ||
52 WARN(prev->next != entry,
53 "list_del corruption. prev->next should be %p, "
54 "but was %p\n", entry, prev->next) ||
55 WARN(next->prev != entry,
56 "list_del corruption. next->prev should be %p, "
57 "but was %p\n", entry, next->prev))
58 return;
59
60 __list_del(prev, next);
61}
62EXPORT_SYMBOL(__list_del_entry);
63
199a9afc
DJ
64/**
65 * list_del - deletes entry from list.
66 * @entry: the element to delete from the list.
67 * Note: list_empty on entry does not return true after this, the entry is
68 * in an undefined state.
69 */
70void list_del(struct list_head *entry)
71{
3c18d4de 72 __list_del_entry(entry);
199a9afc
DJ
73 entry->next = LIST_POISON1;
74 entry->prev = LIST_POISON2;
75}
76EXPORT_SYMBOL(list_del);