Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Rothwell | 7b2c3c5 | 2007-09-17 14:08:06 +1000 | [diff] [blame] | 2 | #include <linux/types.h> |
3 | #include <linux/init.h> | ||||
4 | #include <linux/slab.h> | ||||
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame^] | 5 | #include <linux/memblock.h> |
Stephen Rothwell | 5669c3c | 2007-10-02 13:37:53 +1000 | [diff] [blame] | 6 | #include <linux/string.h> |
David Howells | ae3a197 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 7 | #include <asm/setup.h> |
Stephen Rothwell | 7b2c3c5 | 2007-09-17 14:08:06 +1000 | [diff] [blame] | 8 | |
Stephen Rothwell | 7b2c3c5 | 2007-09-17 14:08:06 +1000 | [diff] [blame] | 9 | |
Fabian Frederick | bd721ea | 2016-08-02 14:03:33 -0700 | [diff] [blame] | 10 | void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask) |
Stephen Rothwell | 5669c3c | 2007-10-02 13:37:53 +1000 | [diff] [blame] | 11 | { |
12 | void *p; | ||||
13 | |||||
Michael Ellerman | f691fa1 | 2015-03-30 14:10:37 +1100 | [diff] [blame] | 14 | if (slab_is_available()) |
Stephen Rothwell | 5669c3c | 2007-10-02 13:37:53 +1000 | [diff] [blame] | 15 | p = kzalloc(size, mask); |
16 | else { | ||||
Mike Rapoport | eb31d55 | 2018-10-30 15:08:04 -0700 | [diff] [blame] | 17 | p = memblock_alloc(size, 0); |
Stephen Rothwell | 5669c3c | 2007-10-02 13:37:53 +1000 | [diff] [blame] | 18 | } |
19 | return p; | ||||
20 | } |