]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/staging/wlan-ng/wlan_compat.h
Staging: wlan-ng: Replace WLAN_LOG_WARNING() with printk()
[linux-2.6-omap-h63xx.git] / drivers / staging / wlan-ng / wlan_compat.h
1 /* wlan_compat.h
2 *
3 * Types and macros to aid in portability
4 *
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
6 * --------------------------------------------------------------------
7 *
8 * linux-wlan
9 *
10 *   The contents of this file are subject to the Mozilla Public
11 *   License Version 1.1 (the "License"); you may not use this file
12 *   except in compliance with the License. You may obtain a copy of
13 *   the License at http://www.mozilla.org/MPL/
14 *
15 *   Software distributed under the License is distributed on an "AS
16 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 *   implied. See the License for the specific language governing
18 *   rights and limitations under the License.
19 *
20 *   Alternatively, the contents of this file may be used under the
21 *   terms of the GNU Public License version 2 (the "GPL"), in which
22 *   case the provisions of the GPL are applicable instead of the
23 *   above.  If you wish to allow the use of your version of this file
24 *   only under the terms of the GPL and not to allow others to use
25 *   your version of this file under the MPL, indicate your decision
26 *   by deleting the provisions above and replace them with the notice
27 *   and other provisions required by the GPL.  If you do not delete
28 *   the provisions above, a recipient may use your version of this
29 *   file under either the MPL or the GPL.
30 *
31 * --------------------------------------------------------------------
32 *
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
35 *
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
39 *
40 * --------------------------------------------------------------------
41 *
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
44 *
45 * --------------------------------------------------------------------
46 */
47
48 #ifndef _WLAN_COMPAT_H
49 #define _WLAN_COMPAT_H
50
51 /*=============================================================*/
52 /*------ OS Portability Macros --------------------------------*/
53 /*=============================================================*/
54
55 #ifndef WLAN_DBVAR
56 #define WLAN_DBVAR      wlan_debug
57 #endif
58
59 #include <linux/hardirq.h>
60
61 #if defined(WLAN_INCLUDE_DEBUG)
62         #define WLAN_HEX_DUMP( l, x, p, n)      if( WLAN_DBVAR >= (l) ){ \
63                 int __i__; \
64                 printk(KERN_DEBUG x ":"); \
65                 for( __i__=0; __i__ < (n); __i__++) \
66                         printk( " %02x", ((u8*)(p))[__i__]); \
67                 printk("\n"); }
68
69         #define WLAN_LOG_DEBUG(l,x,args...) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s(%lu): " x ,  __func__, (preempt_count() & PREEMPT_MASK), ##args );
70 #else
71         #define WLAN_HEX_DUMP( l, s, p, n)
72
73         #define WLAN_LOG_DEBUG(l, s, args...)
74 #endif
75
76 #undef netdevice_t
77 typedef struct net_device netdevice_t;
78
79 /*=============================================================*/
80 /*--- General Macros ------------------------------------------*/
81 /*=============================================================*/
82
83 #define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
84
85 #define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
86
87 /* Create a string of printable chars from something that might not be */
88 /* It's recommended that the str be 4*len + 1 bytes long */
89 #define wlan_mkprintstr(buf, buflen, str, strlen) \
90 { \
91         int i = 0; \
92         int j = 0; \
93         memset(str, 0, (strlen)); \
94         for (i = 0; i < (buflen); i++) { \
95                 if ( wlan_isprint((buf)[i]) ) { \
96                         (str)[j] = (buf)[i]; \
97                         j++; \
98                 } else { \
99                         (str)[j] = '\\'; \
100                         (str)[j+1] = 'x'; \
101                         (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
102                         (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
103                         j += 4; \
104                 } \
105         } \
106 }
107
108 /*=============================================================*/
109 /*--- Variables -----------------------------------------------*/
110 /*=============================================================*/
111
112 #ifdef WLAN_INCLUDE_DEBUG
113 extern int wlan_debug;
114 #endif
115
116 #endif /* _WLAN_COMPAT_H */