aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSteve Wise <swise@opengridcomputing.com>2006-10-02 05:17:00 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 10:57:12 -0400
commit322acc96d4bd3debea11cd0160b18bd5d7ff0d73 (patch)
tree230e9c35e0ce4dac5bd1a49085152624045fb616 /lib
parentd834c16516d1ebec4766fc58c059bf01311e6045 (diff)
[PATCH] LIB: add gen_pool_destroy()
Modules using the genpool allocator need to be able to destroy the data structure when unloading. Signed-off-by: Steve Wise <swise@opengridcomputing.com> Cc: Randy Dunlap <rdunlap@xenotime.net> Cc: Dean Nelson <dcn@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/genalloc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 71338b48e88..7d16ecabba9 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -71,6 +71,36 @@ EXPORT_SYMBOL(gen_pool_add);
71 71
72 72
73/* 73/*
74 * Destroy a memory pool. Verifies that there are no outstanding allocations.
75 *
76 * @pool: pool to destroy
77 */
78void gen_pool_destroy(struct gen_pool *pool)
79{
80 struct list_head *_chunk, *_next_chunk;
81 struct gen_pool_chunk *chunk;
82 int order = pool->min_alloc_order;
83 int bit, end_bit;
84
85
86 write_lock(&pool->lock);
87 list_for_each_safe(_chunk, _next_chunk, &pool->chunks) {
88 chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
89 list_del(&chunk->next_chunk);
90
91 end_bit = (chunk->end_addr - chunk->start_addr) >> order;
92 bit = find_next_bit(chunk->bits, end_bit, 0);
93 BUG_ON(bit < end_bit);
94
95 kfree(chunk);
96 }
97 kfree(pool);
98 return;
99}
100EXPORT_SYMBOL(gen_pool_destroy);
101
102
103/*
74 * Allocate the requested number of bytes from the specified pool. 104 * Allocate the requested number of bytes from the specified pool.
75 * Uses a first-fit algorithm. 105 * Uses a first-fit algorithm.
76 * 106 *