Stephen Rothwell | 7b2c3c5 | 2007-09-17 14:08:06 +1000 | [diff] [blame] | 1 | #include <linux/types.h> |
| 2 | #include <linux/init.h> |
| 3 | #include <linux/slab.h> |
| 4 | #include <linux/bootmem.h> |
Stephen Rothwell | 5669c3c | 2007-10-02 13:37:53 +1000 | [diff] [blame] | 5 | #include <linux/string.h> |
Stephen Rothwell | 7b2c3c5 | 2007-09-17 14:08:06 +1000 | [diff] [blame] | 6 | |
| 7 | #include <asm/system.h> |
| 8 | |
| 9 | void * __init_refok alloc_maybe_bootmem(size_t size, gfp_t mask) |
| 10 | { |
| 11 | if (mem_init_done) |
| 12 | return kmalloc(size, mask); |
| 13 | else |
| 14 | return alloc_bootmem(size); |
| 15 | } |
Stephen Rothwell | 5669c3c | 2007-10-02 13:37:53 +1000 | [diff] [blame] | 16 | |
| 17 | void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask) |
| 18 | { |
| 19 | void *p; |
| 20 | |
| 21 | if (mem_init_done) |
| 22 | p = kzalloc(size, mask); |
| 23 | else { |
| 24 | p = alloc_bootmem(size); |
| 25 | if (p) |
| 26 | memset(p, 0, size); |
| 27 | } |
| 28 | return p; |
| 29 | } |