blob: f53e09c7dac72d95af83ccdca072ccde135db6af [file] [log] [blame]
Stephen Rothwell7b2c3c52007-09-17 14:08:06 +10001#include <linux/types.h>
2#include <linux/init.h>
3#include <linux/slab.h>
4#include <linux/bootmem.h>
Stephen Rothwell5669c3c2007-10-02 13:37:53 +10005#include <linux/string.h>
Stephen Rothwell7b2c3c52007-09-17 14:08:06 +10006
7#include <asm/system.h>
8
9void * __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 Rothwell5669c3c2007-10-02 13:37:53 +100016
17void * __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}