xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/amd/powerplay/inc/pp_debug.h (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: pp_debug.h,v 1.2 2021/12/18 23:45:26 riastradh Exp $	*/
2 
3 
4 /*
5  * Copyright 2015 Advanced Micro Devices, Inc.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * OTHER DEALINGS IN THE SOFTWARE.
24  *
25  */
26 #ifndef PP_DEBUG_H
27 #define PP_DEBUG_H
28 
29 #ifdef pr_fmt
30 #undef pr_fmt
31 #endif
32 
33 #define pr_fmt(fmt) "amdgpu: [powerplay] " fmt
34 
35 #include <linux/types.h>
36 #include <linux/kernel.h>
37 #include <linux/slab.h>
38 
39 #define PP_ASSERT_WITH_CODE(cond, msg, code)	\
40 	do {					\
41 		if (!(cond)) {			\
42 			pr_warn("%s\n", msg);	\
43 			code;			\
44 		}				\
45 	} while (0)
46 
47 #define PP_ASSERT(cond, msg)	\
48 	do {					\
49 		if (!(cond)) {			\
50 			pr_warn("%s\n", msg);	\
51 		}				\
52 	} while (0)
53 
54 #define PP_DBG_LOG(fmt, ...) \
55 	do { \
56 		pr_debug(fmt, ##__VA_ARGS__); \
57 	} while (0)
58 
59 
60 #define GET_FLEXIBLE_ARRAY_MEMBER_ADDR(type, member, ptr, n)	\
61 	(type *)((char *)&(ptr)->member + (sizeof(type) * (n)))
62 
63 #endif /* PP_DEBUG_H */
64 
65