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> |
David Howells | ae3a197 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 6 | #include <asm/setup.h> |
Stephen Rothwell | 7b2c3c5 | 2007-09-17 14:08:06 +1000 | [diff] [blame] | 7 | |
Stephen Rothwell | 7b2c3c5 | 2007-09-17 14:08:06 +1000 | [diff] [blame] | 8 | |
Fabian Frederick | bd721ea | 2016-08-02 14:03:33 -0700 | [diff] [blame] | 9 | void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask) |
Stephen Rothwell | 5669c3c | 2007-10-02 13:37:53 +1000 | [diff] [blame] | 10 | { |
11 | void *p; | ||||
12 | |||||
Michael Ellerman | f691fa1 | 2015-03-30 14:10:37 +1100 | [diff] [blame] | 13 | if (slab_is_available()) |
Stephen Rothwell | 5669c3c | 2007-10-02 13:37:53 +1000 | [diff] [blame] | 14 | p = kzalloc(size, mask); |
15 | else { | ||||
Michael Ellerman | e39f223f | 2014-11-18 16:47:35 +1100 | [diff] [blame] | 16 | p = memblock_virt_alloc(size, 0); |
Stephen Rothwell | 5669c3c | 2007-10-02 13:37:53 +1000 | [diff] [blame] | 17 | } |
18 | return p; | ||||
19 | } |