Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
[sfrench/cifs-2.6.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 /*------ Bit settings -----------------------------------------*/
53 /*=============================================================*/
54
55 #define BIT0    0x00000001
56 #define BIT1    0x00000002
57 #define BIT2    0x00000004
58 #define BIT3    0x00000008
59 #define BIT4    0x00000010
60 #define BIT5    0x00000020
61 #define BIT6    0x00000040
62 #define BIT7    0x00000080
63 #define BIT8    0x00000100
64 #define BIT9    0x00000200
65 #define BIT10   0x00000400
66 #define BIT11   0x00000800
67 #define BIT12   0x00001000
68 #define BIT13   0x00002000
69 #define BIT14   0x00004000
70 #define BIT15   0x00008000
71 #define BIT16   0x00010000
72 #define BIT17   0x00020000
73 #define BIT18   0x00040000
74 #define BIT19   0x00080000
75 #define BIT20   0x00100000
76 #define BIT21   0x00200000
77 #define BIT22   0x00400000
78 #define BIT23   0x00800000
79 #define BIT24   0x01000000
80 #define BIT25   0x02000000
81 #define BIT26   0x04000000
82 #define BIT27   0x08000000
83 #define BIT28   0x10000000
84 #define BIT29   0x20000000
85 #define BIT30   0x40000000
86 #define BIT31   0x80000000
87
88 /*=============================================================*/
89 /*------ Compiler Portability Macros --------------------------*/
90 /*=============================================================*/
91 #define __WLAN_ATTRIB_PACK__            __attribute__ ((packed))
92
93 /*=============================================================*/
94 /*------ OS Portability Macros --------------------------------*/
95 /*=============================================================*/
96
97 #ifndef WLAN_DBVAR
98 #define WLAN_DBVAR      wlan_debug
99 #endif
100
101 #define WLAN_RELEASE    "0.3.0-lkml"
102
103 #include <linux/hardirq.h>
104
105 #define WLAN_LOG_ERROR(x,args...) printk(KERN_ERR "%s: " x , __func__ , ##args);
106
107 #define WLAN_LOG_WARNING(x,args...) printk(KERN_WARNING "%s: " x , __func__ , ##args);
108
109 #define WLAN_LOG_NOTICE(x,args...) printk(KERN_NOTICE "%s: " x , __func__ , ##args);
110
111 #define WLAN_LOG_INFO(args... ) printk(KERN_INFO args)
112
113 #if defined(WLAN_INCLUDE_DEBUG)
114         #define WLAN_HEX_DUMP( l, x, p, n)      if( WLAN_DBVAR >= (l) ){ \
115                 int __i__; \
116                 printk(KERN_DEBUG x ":"); \
117                 for( __i__=0; __i__ < (n); __i__++) \
118                         printk( " %02x", ((u8*)(p))[__i__]); \
119                 printk("\n"); }
120         #define DBFENTER { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"---->\n"); } }
121         #define DBFEXIT  { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"<----\n"); } }
122
123         #define WLAN_LOG_DEBUG(l,x,args...) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s(%lu): " x ,  __func__, (preempt_count() & PREEMPT_MASK), ##args );
124 #else
125         #define WLAN_HEX_DUMP( l, s, p, n)
126         #define DBFENTER
127         #define DBFEXIT
128
129         #define WLAN_LOG_DEBUG(l, s, args...)
130 #endif
131
132 #undef netdevice_t
133 typedef struct net_device netdevice_t;
134
135 #define URB_ASYNC_UNLINK 0
136 #define USB_QUEUE_BULK 0
137
138 /*=============================================================*/
139 /*------ Hardware Portability Macros --------------------------*/
140 /*=============================================================*/
141
142 #define ieee2host16(n)  __le16_to_cpu(n)
143 #define ieee2host32(n)  __le32_to_cpu(n)
144 #define host2ieee16(n)  __cpu_to_le16(n)
145 #define host2ieee32(n)  __cpu_to_le32(n)
146
147 /*=============================================================*/
148 /*--- General Macros ------------------------------------------*/
149 /*=============================================================*/
150
151 #define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
152 #define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
153
154 #define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
155
156 #define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
157
158 /* Create a string of printable chars from something that might not be */
159 /* It's recommended that the str be 4*len + 1 bytes long */
160 #define wlan_mkprintstr(buf, buflen, str, strlen) \
161 { \
162         int i = 0; \
163         int j = 0; \
164         memset(str, 0, (strlen)); \
165         for (i = 0; i < (buflen); i++) { \
166                 if ( wlan_isprint((buf)[i]) ) { \
167                         (str)[j] = (buf)[i]; \
168                         j++; \
169                 } else { \
170                         (str)[j] = '\\'; \
171                         (str)[j+1] = 'x'; \
172                         (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
173                         (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
174                         j += 4; \
175                 } \
176         } \
177 }
178
179 /*=============================================================*/
180 /*--- Variables -----------------------------------------------*/
181 /*=============================================================*/
182
183 #ifdef WLAN_INCLUDE_DEBUG
184 extern int wlan_debug;
185 #endif
186
187 extern int wlan_ethconv;                /* What's the default ethconv? */
188
189 /*=============================================================*/
190 /*--- Functions -----------------------------------------------*/
191 /*=============================================================*/
192 #endif /* _WLAN_COMPAT_H */
193