diff options
| author | Jeff Garzik <jgarzik@pretzel.yyz.us> | 2005-06-22 13:07:28 -0400 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2005-06-22 13:07:28 -0400 |
| commit | ff40c6d3d1437ecdf295b8e39adcb06c3d6021ef (patch) | |
| tree | 3666d029b4bd4df2909dbefd9c7a09e6042b7d32 /include/linux/genalloc.h | |
| parent | 8bf62ecee58360749c5f0e68bc97d5e02a6816b1 (diff) | |
| parent | 2a5a68b840cbab31baab2d9b2e1e6de3b289ae1e (diff) | |
Merge upstream kernel changes into 'C/H/S support' branch of libata.
Diffstat (limited to 'include/linux/genalloc.h')
| -rw-r--r-- | include/linux/genalloc.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h new file mode 100644 index 0000000000..7fd0576a44 --- /dev/null +++ b/include/linux/genalloc.h | |||
| @@ -0,0 +1,40 @@ | |||
| 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 code is based on the buddy allocator found in the sym53c8xx_2 | ||
| 8 | * driver, adapted for general purpose use. | ||
| 9 | * | ||
| 10 | * This source code is licensed under the GNU General Public License, | ||
| 11 | * Version 2. See the file COPYING for more details. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/spinlock.h> | ||
| 15 | |||
| 16 | #define ALLOC_MIN_SHIFT 5 /* 32 bytes minimum */ | ||
| 17 | /* | ||
| 18 | * Link between free memory chunks of a given size. | ||
| 19 | */ | ||
| 20 | struct gen_pool_link { | ||
| 21 | struct gen_pool_link *next; | ||
| 22 | }; | ||
| 23 | |||
| 24 | /* | ||
| 25 | * Memory pool descriptor. | ||
| 26 | */ | ||
| 27 | struct gen_pool { | ||
| 28 | spinlock_t lock; | ||
| 29 | unsigned long (*get_new_chunk)(struct gen_pool *); | ||
| 30 | struct gen_pool *next; | ||
| 31 | struct gen_pool_link *h; | ||
| 32 | unsigned long private; | ||
| 33 | int max_chunk_shift; | ||
| 34 | }; | ||
| 35 | |||
| 36 | unsigned long gen_pool_alloc(struct gen_pool *poolp, int size); | ||
| 37 | void gen_pool_free(struct gen_pool *mp, unsigned long ptr, int size); | ||
| 38 | struct gen_pool *gen_pool_create(int nr_chunks, int max_chunk_shift, | ||
| 39 | unsigned long (*fp)(struct gen_pool *), | ||
| 40 | unsigned long data); | ||
