blob: eebf5e5696ec3b31323303a354026507b54ded52 [file] [log] [blame]
mochel@digitalimplant.org9a19fea2005-03-21 11:45:16 -08001/*
2 * klist.h - Some generic list helpers, extending struct list_head a bit.
3 *
4 * Implementations are found in lib/klist.c
5 *
6 *
7 * Copyright (C) 2005 Patrick Mochel
8 *
9 * This file is rleased under the GPL v2.
10 */
11
12#include <linux/spinlock.h>
13#include <linux/completion.h>
14#include <linux/kref.h>
15#include <linux/list.h>
16
17
18struct klist {
19 spinlock_t k_lock;
20 struct list_head k_list;
21};
22
23
24extern void klist_init(struct klist * k);
25
26
27struct klist_node {
28 struct klist * n_klist;
29 struct list_head n_node;
30 struct kref n_ref;
31 struct completion n_removed;
32};
33
34extern void klist_add_tail(struct klist * k, struct klist_node * n);
35extern void klist_add_head(struct klist * k, struct klist_node * n);
36
37extern void klist_del(struct klist_node * n);
38extern void klist_remove(struct klist_node * n);
39
mochel@digitalimplant.org8b0c2502005-03-24 12:58:57 -080040extern int klist_node_attached(struct klist_node * n);
41
mochel@digitalimplant.org9a19fea2005-03-21 11:45:16 -080042
43struct klist_iter {
44 struct klist * i_klist;
45 struct list_head * i_head;
46 struct klist_node * i_cur;
47};
48
49
50extern void klist_iter_init(struct klist * k, struct klist_iter * i);
51extern void klist_iter_init_node(struct klist * k, struct klist_iter * i,
52 struct klist_node * n);
53extern void klist_iter_exit(struct klist_iter * i);
54extern struct klist_node * klist_next(struct klist_iter * i);
55