1 /*
2  * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: i_qdf_talloc.h
22  *
23  * Linux-specific definitions for use by QDF talloc APIs
24  */
25 
26 #ifndef __I_QDF_TALLOC_H
27 #define __I_QDF_TALLOC_H
28 
29 #include "asm/page.h"
30 #include "linux/irqflags.h"
31 #include "linux/preempt.h"
32 #include "linux/slab.h"
33 
34 #define __can_sleep() \
35 	(!in_interrupt() && !irqs_disabled() && !in_atomic())
36 
37 #define __zalloc_sleeps(size) kzalloc(size, GFP_KERNEL)
38 #define __zalloc_atomic(size) kzalloc(size, GFP_ATOMIC)
39 #define __zalloc_auto(size) \
40 	kzalloc(size, __can_sleep() ? GFP_KERNEL : GFP_ATOMIC)
41 
42 #define __k_free(ptr) kfree(ptr)
43 
44 #define __qdf_alloc_size(ptr) ksize(ptr)
45 
46 #endif /* __I_QDF_TALLOC_H */
47 
48