Преглед изворни кода

[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
mochel@digitalimplant.org пре 20 година
родитељ
комит
8b0c250be4
2 измењених фајлова са 18 додато и 0 уклоњено
  1. 2 0
      include/linux/klist.h
  2. 16 0
      lib/klist.c

+ 2 - 0
include/linux/klist.h

@@ -37,6 +37,8 @@ extern void klist_add_head(struct klist * k, struct klist_node * n);
 extern void klist_del(struct klist_node * n);
 extern void klist_del(struct klist_node * n);
 extern void klist_remove(struct klist_node * n);
 extern void klist_remove(struct klist_node * n);
 
 
+extern int klist_node_attached(struct klist_node * n);
+
 
 
 struct klist_iter {
 struct klist_iter {
 	struct klist		* i_klist;
 	struct klist		* i_klist;

+ 16 - 0
lib/klist.c

@@ -112,6 +112,7 @@ static void klist_release(struct kref * kref)
 	struct klist_node * n = container_of(kref, struct klist_node, n_ref);
 	struct klist_node * n = container_of(kref, struct klist_node, n_ref);
 	list_del(&n->n_node);
 	list_del(&n->n_node);
 	complete(&n->n_removed);
 	complete(&n->n_removed);
+	n->n_klist = NULL;
 }
 }
 
 
 static int klist_dec_and_del(struct klist_node * n)
 static int klist_dec_and_del(struct klist_node * n)
@@ -153,6 +154,19 @@ void klist_remove(struct klist_node * n)
 EXPORT_SYMBOL_GPL(klist_remove);
 EXPORT_SYMBOL_GPL(klist_remove);
 
 
 
 
+/**
+ *	klist_node_attached - Say whether a node is bound to a list or not.
+ *	@n:	Node that we're testing.
+ */
+
+int klist_node_attached(struct klist_node * n)
+{
+	return (n->n_klist != NULL);
+}
+
+EXPORT_SYMBOL_GPL(klist_node_attached);
+
+
 /**
 /**
  *	klist_iter_init_node - Initialize a klist_iter structure.
  *	klist_iter_init_node - Initialize a klist_iter structure.
  *	@k:	klist we're iterating.
  *	@k:	klist we're iterating.
@@ -246,3 +260,5 @@ struct klist_node * klist_next(struct klist_iter * i)
 }
 }
 
 
 EXPORT_SYMBOL_GPL(klist_next);
 EXPORT_SYMBOL_GPL(klist_next);
+
+