d3db6266f6e38145cb84dafd356db80608bfc7cd
[linux-2.6-block.git] / drivers / staging / wlags49_h2 / debug.h
1 /*******************************************************************************
2  * Agere Systems Inc.
3  * Wireless device driver for Linux (wlags49).
4  *
5  * Copyright (c) 1998-2003 Agere Systems Inc.
6  * All rights reserved.
7  *   http://www.agere.com
8  *
9  * Initially developed by TriplePoint, Inc.
10  *   http://www.triplepoint.com
11  *
12  *------------------------------------------------------------------------------
13  *
14  *   This file contains definitions and macros for debugging.
15  *
16  *------------------------------------------------------------------------------
17  *
18  * SOFTWARE LICENSE
19  *
20  * This software is provided subject to the following terms and conditions,
21  * which you should read carefully before using the software.  Using this
22  * software indicates your acceptance of these terms and conditions.  If you do
23  * not agree with these terms and conditions, do not use the software.
24  *
25  * Copyright © 2003 Agere Systems Inc.
26  * All rights reserved.
27  *
28  * Redistribution and use in source or binary forms, with or without
29  * modifications, are permitted provided that the following conditions are met:
30  *
31  * . Redistributions of source code must retain the above copyright notice, this
32  *    list of conditions and the following Disclaimer as comments in the code as
33  *    well as in the documentation and/or other materials provided with the
34  *    distribution.
35  *
36  * . Redistributions in binary form must reproduce the above copyright notice,
37  *    this list of conditions and the following Disclaimer in the documentation
38  *    and/or other materials provided with the distribution.
39  *
40  * . Neither the name of Agere Systems Inc. nor the names of the contributors
41  *    may be used to endorse or promote products derived from this software
42  *    without specific prior written permission.
43  *
44  * Disclaimer
45  *
46  * THIS SOFTWARE IS PROVIDED \93AS IS\94 AND ANY EXPRESS OR IMPLIED WARRANTIES,
47  * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
48  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ANY
49  * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
50  * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
51  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54  * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
55  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
56  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
57  * DAMAGE.
58  *
59  ******************************************************************************/
60
61
62
63
64 /*******************************************************************************
65  * VERSION CONTROL INFORMATION
66  *******************************************************************************
67  *
68  * $Author: nico $
69  * $Date: 2004/07/20 09:29:45 $
70  * $Revision: 1.3 $
71  * $Source: /usr/local/cvs/wl_lkm/include/hcf/debug.h,v $
72  *
73  ******************************************************************************/
74
75
76
77
78 #ifndef _DEBUG_H
79 #define _DEBUG_H
80
81
82
83
84 /* Turn on debugging here if not done with a preprocessor define */
85 #ifndef DBG
86 #define DBG 0
87 #else
88 #undef  DBG
89 #define DBG 1
90 #endif //DBG
91
92
93
94
95 #if DBG
96 /****************************************************************************/
97
98 /* Set the level of debugging if not done with a preprocessor define. See
99    wl_main.c, init_module() for how the debug level translates into the
100    the types of messages displayed */
101 #ifndef DBG_LVL
102 #define DBG_LVL 5                       /* yields nothing via init_module,
103                                                            original value of 5 yields DBG_TRACE_ON and DBG_VERBOSE_ON */
104 #endif  // DBG_LVL
105
106
107 #define DBG_ERROR_ON        0x00000001L
108 #define DBG_WARNING_ON      0x00000002L
109 #define DBG_NOTICE_ON       0x00000004L
110 #define DBG_TRACE_ON        0x00000008L
111 #define DBG_VERBOSE_ON      0x00000010L
112 #define DBG_PARAM_ON        0x00000020L
113 #define DBG_BREAK_ON        0x00000040L
114 #define DBG_RX_ON           0x00000100L
115 #define DBG_TX_ON           0x00000200L
116 #define DBG_DS_ON           0x00000400L
117
118 #define DBG_DEFAULTS        (DBG_ERROR_ON | DBG_WARNING_ON | DBG_BREAK_ON)
119
120 #define DBG_FLAGS(A)        (A)->DebugFlag
121 #define DBG_NAME(A)         (A)->dbgName
122 #define DBG_LEVEL(A)        (A)->dbgLevel
123
124
125 #ifndef PRINTK
126 #   define PRINTK(S...)     printk(S)
127 #endif // PRINTK
128
129
130 #ifndef DBG_PRINT
131 #   define DBG_PRINT(S...)  PRINTK(KERN_DEBUG S)
132 #endif // DBG_PRINT
133
134
135 #ifndef DBG_PRINTC
136 #   define DBG_PRINTC(S...) PRINTK(S)
137 #endif // DBG_PRINTC
138
139
140 #ifndef DBG_TRAP
141 #   define DBG_TRAP         {}
142 #endif // DBG_TRAP
143
144
145 #define _ENTER_STR          ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
146 #define _LEAVE_STR          "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
147
148
149 #define _DBG_ENTER(A)       DBG_PRINT("%s:%.*s:%s\n",DBG_NAME(A),++DBG_LEVEL(A),_ENTER_STR,__FUNC__)
150 #define _DBG_LEAVE(A)       DBG_PRINT("%s:%.*s:%s\n",DBG_NAME(A),DBG_LEVEL(A)--,_LEAVE_STR,__FUNC__)
151
152
153 #define DBG_FUNC(F)         static const char *__FUNC__ = F;
154
155 #define DBG_ENTER(A)        {if (DBG_FLAGS(A) & DBG_TRACE_ON) _DBG_ENTER(A);}
156
157 #define DBG_LEAVE(A)        {if (DBG_FLAGS(A) & DBG_TRACE_ON) _DBG_LEAVE(A);}
158
159 #define DBG_PARAM(A,N,F,S...)   {if (DBG_FLAGS(A) & DBG_PARAM_ON) \
160                                     DBG_PRINT("  %s -- "F"\n",N,S);}
161
162
163 #define DBG_ERROR(A,S...)   {if (DBG_FLAGS(A) & DBG_ERROR_ON) \
164                                 {DBG_PRINT("%s:ERROR:%s ",DBG_NAME(A),__FUNC__);DBG_PRINTC(S);DBG_TRAP;}}
165
166
167 #define DBG_WARNING(A,S...) {if (DBG_FLAGS(A) & DBG_WARNING_ON) \
168                                 {DBG_PRINT("%s:WARNING:%s ",DBG_NAME(A),__FUNC__);DBG_PRINTC(S);}}
169
170
171 #define DBG_NOTICE(A,S...)  {if (DBG_FLAGS(A) & DBG_NOTICE_ON) \
172                                 {DBG_PRINT("%s:NOTICE:%s ",DBG_NAME(A),__FUNC__);DBG_PRINTC(S);}}
173
174
175 #define DBG_TRACE(A,S...)   do {if (DBG_FLAGS(A) & DBG_TRACE_ON) \
176                                 {DBG_PRINT("%s:%s ",DBG_NAME(A),__FUNC__);DBG_PRINTC(S);}} while (0)
177
178
179 #define DBG_RX(A,S...)      {if (DBG_FLAGS(A) & DBG_RX_ON) \
180                                 {DBG_PRINT(S);}}
181
182
183 #define DBG_TX(A,S...)      {if (DBG_FLAGS(A) & DBG_TX_ON) \
184                                 {DBG_PRINT(S);}}
185
186 #define DBG_DS(A,S...)      {if (DBG_FLAGS(A) & DBG_DS_ON) \
187                                 {DBG_PRINT(S);}}
188
189
190 #define DBG_ASSERT(C)       {if (!(C)) \
191                                 {DBG_PRINT("ASSERT(%s) -- %s#%d (%s)\n", \
192                                     #C,__FILE__,__LINE__,__FUNC__); \
193                                 DBG_TRAP;}}
194
195 typedef struct {
196     char           *dbgName;
197     int             dbgLevel;
198     unsigned long   DebugFlag;
199 } dbg_info_t;
200
201
202 /****************************************************************************/
203 #else // DBG
204 /****************************************************************************/
205
206 #define DBG_DEFN
207 #define DBG_TRAP
208 #define DBG_FUNC(F)
209 #define DBG_PRINT(S...)
210 #define DBG_ENTER(A)
211 #define DBG_LEAVE(A)
212 #define DBG_PARAM(A,N,F,S...)
213 #define DBG_ERROR(A,S...)
214 #define DBG_WARNING(A,S...)
215 #define DBG_NOTICE(A,S...)
216 #define DBG_TRACE(A,S...)
217 #define DBG_RX(A,S...)
218 #define DBG_TX(A,S...)
219 #define DBG_DS(A,S...)
220 #define DBG_ASSERT(C)
221
222 #endif // DBG
223 /****************************************************************************/
224
225
226
227
228 #endif // _DEBUG_H
229