blob: 60b0b3fc8fc19725b60e660e41fe48ebb5ea757a [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>
David Howellsae3a1972012-03-28 18:30:02 +01006#include <asm/setup.h>
Stephen Rothwell7b2c3c52007-09-17 14:08:06 +10007
Stephen Rothwell7b2c3c52007-09-17 14:08:06 +10008
Stephen Rothwell5669c3c2007-10-02 13:37:53 +10009void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
10{
11 void *p;
12
Michael Ellermanf691fa12015-03-30 14:10:37 +110013 if (slab_is_available())
Stephen Rothwell5669c3c2007-10-02 13:37:53 +100014 p = kzalloc(size, mask);
15 else {
Michael Ellermane39f223f2014-11-18 16:47:35 +110016 p = memblock_virt_alloc(size, 0);
Stephen Rothwell5669c3c2007-10-02 13:37:53 +100017 }
18 return p;
19}