summaryrefslogtreecommitdiff
path: root/drivers/input/sensors/bmi160/bs_log.h
blob: ed2d2b37f533c8dfbb382b9a9d11d3d0bbfcdd65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*!
 * @section LICENSE
 * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
 *
 * This software program is licensed subject to the GNU General
 * Public License (GPL).Version 2,June 1991,
 * available at http://www.fsf.org/copyleft/gpl.html
 *
 * @filename bs_log.h
 * @date     "Sat Oct 11 16:12:16 2014 +0800"
 * @id       "762cc9e"
 *
 * @brief
 * The head file of BOSCH SENSOR LOG
*/

#ifndef __BS_LOG_H
#define __BS_LOG_H

#include <linux/kernel.h>

/*! @ trace functions
 @{*/
/*! ERROR LOG LEVEL */
#define LOG_LEVEL_E 3
/*! NOTICE LOG LEVEL */
#define LOG_LEVEL_N 5
/*! INFORMATION LOG LEVEL */
#define LOG_LEVEL_I 6
/*! DEBUG LOG LEVEL */
#define LOG_LEVEL_D 7
/*! DEBUG_FWDL LOG LEVEL */
#define LOG_LEVEL_DF 10
/*! DEBUG_DATA LOG LEVEL */
#define LOG_LEVEL_DA 15
/*! ALL LOG LEVEL */
#define LOG_LEVEL_A 20

#ifndef MODULE_TAG
/*! MODULE TAG DEFINATION */
#define MODULE_TAG "<BS_LOG>"
#endif

#ifndef LOG_LEVEL
/*! LOG LEVEL DEFINATION */
#define LOG_LEVEL LOG_LEVEL_I
#endif

#ifdef BOSCH_DRIVER_LOG_FUNC
	#ifdef BSLOG_VAR_DEF
		uint8_t debug_log_level = LOG_LEVEL;
	#else
		extern uint8_t debug_log_level;
	#endif

	/*! print error message */
	#define PERR(fmt, args...) do\
	{\
		if (debug_log_level >= LOG_LEVEL_E)\
			printk(KERN_INFO "\n" "[E]" KERN_ERR MODULE_TAG \
				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
	} while (0)

	/*! print notice message */
	#define PNOTICE(fmt, args...) do\
	{\
		if (debug_log_level >= LOG_LEVEL_N)\
			printk(KERN_INFO "\n" "[N]" KERN_NOTICE MODULE_TAG \
				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
	} while (0)

	/*! print information message */
	#define PINFO(fmt, args...) do\
	{\
		if (debug_log_level >= LOG_LEVEL_I)\
			printk(KERN_INFO "\n" "[I]" KERN_INFO MODULE_TAG \
				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
	} while (0)

	/*! print debug message */
	#define PDEBUG(fmt, args...) do\
	{\
		if (debug_log_level >= LOG_LEVEL_D)\
			printk(KERN_INFO "\n" "[D]" KERN_DEBUG MODULE_TAG \
				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
	} while (0)

	/*! print debug fw download message */
	#define PDEBUG_FWDL(fmt, args...) do\
	{\
		if (debug_log_level >= LOG_LEVEL_DF)\
			printk(KERN_INFO "\n" "[DF]" KERN_DEBUG MODULE_TAG \
				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
	} while (0)

	/*! print debug data log message */
	#define PDEBUG_DLOG(fmt, args...) do\
	{\
		if (debug_log_level >= LOG_LEVEL_DA)\
			printk(KERN_INFO "\n" "[DA]" KERN_DEBUG MODULE_TAG \
				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
	} while (0)

	void set_debug_log_level(uint8_t level);
	uint8_t get_debug_log_level(void);

#else

	#if (LOG_LEVEL >= LOG_LEVEL_E)
	/*! print error message */
	#define PERR(fmt, args...) \
		printk(KERN_INFO "\n" "[E]" KERN_ERR MODULE_TAG \
		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
	#else
	/*! invalid message */
	#define PERR(fmt, args...)
	#endif

	#if (LOG_LEVEL >= LOG_LEVEL_N)
	/*! print notice message */
	#define PNOTICE(fmt, args...) \
		printk(KERN_INFO "\n" "[N]" KERN_NOTICE MODULE_TAG \
		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
	#else
	/*! invalid message */
	#define PNOTICE(fmt, args...)
	#endif

	#if (LOG_LEVEL >= LOG_LEVEL_I)
	/*! print information message */
	#define PINFO(fmt, args...) printk(KERN_INFO "\n" "[I]" KERN_INFO MODULE_TAG \
		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
	#else
	/*! invalid message */
	#define PINFO(fmt, args...)
	#endif

	#if (LOG_LEVEL >= LOG_LEVEL_D)
	/*! print debug message */
	#define PDEBUG(fmt, args...) printk(KERN_INFO "\n" "[D]" KERN_DEBUG MODULE_TAG \
		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
	#else
	/*! invalid message */
	#define PDEBUG(fmt, args...)
	#endif

	#if (LOG_LEVEL >= LOG_LEVEL_DF)
	/*! print debug fw download message */
	#define PDEBUG_FWDL(fmt, args...) printk(KERN_INFO "\n" "[DF]" KERN_DEBUG MODULE_TAG \
		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
	#else
	/*! invalid message */
	#define PDEBUG_FWDL(fmt, args...)
	#endif

	#if (LOG_LEVEL >= LOG_LEVEL_DA)
	/*! print debug data log message */
	#define PDEBUG_DLOG(fmt, args...) printk(KERN_INFO "\n" "[DA]" KERN_DEBUG MODULE_TAG \
		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
	#else
	/*! invalid message */
	#define PDEBUG_DLOG(fmt, args...)
	#endif

	#define set_debug_log_level(level) {}
	#define get_debug_log_level() (LOG_LEVEL)

#endif

#endif/*__BS_LOG_H*/
/*@}*/