ASoC: Move kfree(twl4030) to twl4030_soc_remove()
[linux-2.6/btrfs-unstable.git] / include / linux / decompress / mm.h
blobad5ec1d0475ee9f10a0dadfde8c9ad3c29156b79
1 /*
2 * linux/compr_mm.h
4 * Memory management for pre-boot and ramdisk uncompressors
6 * Authors: Alain Knaff <alain@knaff.lu>
8 */
10 #ifndef DECOMPR_MM_H
11 #define DECOMPR_MM_H
13 #ifdef STATIC
15 /* Code active when included from pre-boot environment: */
18 * Some architectures want to ensure there is no local data in their
19 * pre-boot environment, so that data can arbitarily relocated (via
20 * GOT references). This is achieved by defining STATIC_RW_DATA to
21 * be null.
23 #ifndef STATIC_RW_DATA
24 #define STATIC_RW_DATA static
25 #endif
27 /* A trivial malloc implementation, adapted from
28 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
30 STATIC_RW_DATA unsigned long malloc_ptr;
31 STATIC_RW_DATA int malloc_count;
33 static void *malloc(int size)
35 void *p;
37 if (size < 0)
38 return NULL;
39 if (!malloc_ptr)
40 malloc_ptr = free_mem_ptr;
42 malloc_ptr = (malloc_ptr + 3) & ~3; /* Align */
44 p = (void *)malloc_ptr;
45 malloc_ptr += size;
47 if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
48 return NULL;
50 malloc_count++;
51 return p;
54 static void free(void *where)
56 malloc_count--;
57 if (!malloc_count)
58 malloc_ptr = free_mem_ptr;
61 #define large_malloc(a) malloc(a)
62 #define large_free(a) free(a)
64 #define set_error_fn(x)
66 #define INIT
68 #else /* STATIC */
70 /* Code active when compiled standalone for use when loading ramdisk: */
72 #include <linux/kernel.h>
73 #include <linux/fs.h>
74 #include <linux/string.h>
75 #include <linux/vmalloc.h>
77 /* Use defines rather than static inline in order to avoid spurious
78 * warnings when not needed (indeed large_malloc / large_free are not
79 * needed by inflate */
81 #define malloc(a) kmalloc(a, GFP_KERNEL)
82 #define free(a) kfree(a)
84 #define large_malloc(a) vmalloc(a)
85 #define large_free(a) vfree(a)
87 static void(*error)(char *m);
88 #define set_error_fn(x) error = x;
90 #define INIT __init
91 #define STATIC
93 #include <linux/init.h>
95 #endif /* STATIC */
97 #endif /* DECOMPR_MM_H */