Skip to content

Commit 8b0c250

Browse files
mochel@digitalimplant.orggregkh
authored andcommitted
[PATCH] add klist_node_attached() to determine if a node is on a list or not.
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> diff -Nru a/include/linux/klist.h b/include/linux/klist.h
1 parent 2287c32 commit 8b0c250

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎include/linux/klist.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ extern void klist_add_head(struct klist * k, struct klist_node * n);
3737
extern void klist_del(struct klist_node * n);
3838
extern void klist_remove(struct klist_node * n);
3939

40+
extern int klist_node_attached(struct klist_node * n);
41+
4042

4143
struct klist_iter {
4244
struct klist * i_klist;

‎lib/klist.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static void klist_release(struct kref * kref)
112112
struct klist_node * n = container_of(kref, struct klist_node, n_ref);
113113
list_del(&n->n_node);
114114
complete(&n->n_removed);
115+
n->n_klist = NULL;
115116
}
116117

117118
static int klist_dec_and_del(struct klist_node * n)
@@ -153,6 +154,19 @@ void klist_remove(struct klist_node * n)
153154
EXPORT_SYMBOL_GPL(klist_remove);
154155

155156

157+
/**
158+
* klist_node_attached - Say whether a node is bound to a list or not.
159+
* @n: Node that we're testing.
160+
*/
161+
162+
int klist_node_attached(struct klist_node * n)
163+
{
164+
return (n->n_klist != NULL);
165+
}
166+
167+
EXPORT_SYMBOL_GPL(klist_node_attached);
168+
169+
156170
/**
157171
* klist_iter_init_node - Initialize a klist_iter structure.
158172
* @k: klist we're iterating.
@@ -246,3 +260,5 @@ struct klist_node * klist_next(struct klist_iter * i)
246260
}
247261

248262
EXPORT_SYMBOL_GPL(klist_next);
263+
264+

0 commit comments

Comments
 (0)