blob: 77d1cc29c67ab4e184c57c0e97389568d3f88dd6 [file] [log] [blame]
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +05301
2/*
3 * sfe_debug.h
4 * SFE debug macros.
5 *
6 * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21/*
22 * The following are debug macros used throughout the SFE.
23 *
24 * The DEBUG_LEVEL enables the followings based on its value,
25 * when dynamic debug option is disabled.
26 *
27 * 0 = OFF
28 * 1 = ASSERTS / ERRORS
29 * 2 = 1 + WARN
30 * 3 = 2 + INFO
31 * 4 = 3 + TRACE
32 */
33#define DEBUG_LEVEL 2
34
35#if (DEBUG_LEVEL < 1)
36#define DEBUG_ASSERT(s, ...)
37#define DEBUG_ERROR(s, ...)
38#else
39#define DEBUG_ASSERT(c, s, ...) if (!(c)) { pr_emerg("ASSERT: %s:%d:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__); BUG(); }
40#define DEBUG_ERROR(s, ...) pr_err("%s:%d:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
41#endif
42
43#if defined(CONFIG_DYNAMIC_DEBUG)
44/*
45 * Compile messages for dynamic enable/disable
46 */
47#define DEBUG_WARN(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
48#define DEBUG_INFO(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
49#define DEBUG_TRACE(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
50#else
51
52/*
53 * Statically compile messages at different levels
54 */
55#if (DEBUG_LEVEL < 2)
56#define DEBUG_WARN(s, ...)
57#else
58#define DEBUG_WARN(s, ...) pr_warn("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
59#endif
60
61#if (DEBUG_LEVEL < 3)
62#define DEBUG_INFO(s, ...)
63#else
64#define DEBUG_INFO(s, ...) pr_notice("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
65#endif
66
67#if (DEBUG_LEVEL < 4)
68#define DEBUG_TRACE(s, ...)
69#else
70#define DEBUG_TRACE(s, ...) pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
71#endif
72#endif