upload tizen1.0 source
[kernel/linux-2.6.36.git] / include / linux / genalloc.h
1 /*
2  * Basic general purpose allocator for managing special purpose memory
3  * not managed by the regular kmalloc/kfree interface.
4  * Uses for this includes on-device special memory, uncached memory
5  * etc.
6  *
7  * This source code is licensed under the GNU General Public License,
8  * Version 2.  See the file COPYING for more details.
9  */
10
11 struct gen_pool;
12
13 struct gen_pool *__must_check gen_pool_create(unsigned order, int nid);
14
15 int __must_check gen_pool_add(struct gen_pool *pool, unsigned long addr,
16                               size_t size, int nid);
17
18 void gen_pool_destroy(struct gen_pool *pool);
19
20 unsigned long __must_check
21 gen_pool_alloc_aligned(struct gen_pool *pool, size_t size,
22                        unsigned alignment_order);
23
24 /**
25  * gen_pool_alloc() - allocate special memory from the pool
26  * @pool:       Pool to allocate from.
27  * @size:       Number of bytes to allocate from the pool.
28  *
29  * Allocate the requested number of bytes from the specified pool.
30  * Uses a first-fit algorithm.
31  */
32 static inline unsigned long __must_check
33 gen_pool_alloc(struct gen_pool *pool, size_t size)
34 {
35         return gen_pool_alloc_aligned(pool, size, 0);
36 }
37
38 void gen_pool_free(struct gen_pool *pool, unsigned long addr, size_t size);