public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.18 ] LIB Add gen_pool_destroy().
@ 2006-09-27 15:35 Steve Wise
  2006-09-27 15:51 ` Randy Dunlap
  2006-09-27 19:51 ` [PATCH 2.6.18 ] LIB Add gen_pool_destroy() Dean Nelson
  0 siblings, 2 replies; 14+ messages in thread
From: Steve Wise @ 2006-09-27 15:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: dcn, jes, avolkov


Modules using the genpool allocator need to be able to destroy the data
structure when unloading.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
---

 include/linux/genalloc.h |    1 +
 lib/genalloc.c           |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
index 690c428..ca2b119 100644
--- a/include/linux/genalloc.h
+++ b/include/linux/genalloc.h
@@ -30,6 +30,7 @@ struct gen_pool_chunk {
 };
 
 extern struct gen_pool *gen_pool_create(int, int);
+extern void gen_pool_destroy(struct gen_pool *);
 extern int gen_pool_add(struct gen_pool *, unsigned long, size_t, int);
 extern unsigned long gen_pool_alloc(struct gen_pool *, size_t);
 extern void gen_pool_free(struct gen_pool *, unsigned long, size_t);
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 71338b4..c8afa10 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -36,6 +36,28 @@ EXPORT_SYMBOL(gen_pool_create);
 
 
 /*
+ * Destroy a memory pool.  Assumes the user deals with releasing the
+ * actual memory managed by the pool.  
+ *
+ * @pool: pool to destroy.
+ *
+ */
+void gen_pool_destroy(struct gen_pool *pool)
+{
+	struct list_head *_chunk, *next;
+	struct gen_pool_chunk *chunk;
+
+	list_for_each_safe(_chunk, next, &pool->chunks) {
+		chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
+		kfree(chunk);
+	}
+	kfree(pool);
+	return;
+}
+EXPORT_SYMBOL(gen_pool_destroy);
+
+
+/*
  * Add a new chunk of memory to the specified pool.
  *
  * @pool: pool to add new memory chunk to

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2006-09-28 18:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-27 15:35 [PATCH 2.6.18 ] LIB Add gen_pool_destroy() Steve Wise
2006-09-27 15:51 ` Randy Dunlap
2006-09-27 15:53   ` Steve Wise
2006-09-27 15:56     ` Randy Dunlap
2006-09-27 19:59       ` Dean Nelson
2006-09-27 20:27         ` Randy Dunlap
2006-09-28 17:24           ` [PATCH] make genpool allocator adhere to kernel-doc standards Dean Nelson
2006-09-28 17:48             ` Randy Dunlap
2006-09-28 18:17               ` Dean Nelson
2006-09-27 19:51 ` [PATCH 2.6.18 ] LIB Add gen_pool_destroy() Dean Nelson
2006-09-27 21:09   ` Steve Wise
2006-09-28 13:16     ` [PATCH] add gen_pool_destroy() Dean Nelson
2006-09-28 14:51       ` Robin Holt
2006-09-28 15:48         ` Dean Nelson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox