]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/staging/winbond/linux/common.h
sh: asm/gpio.h needs linux/kernel.h for might_sleep()/WARN_ON().
[linux-2.6-omap-h63xx.git] / drivers / staging / winbond / linux / common.h
1 //
2 // common.h
3 //
4 // This file contains the OS dependant definition and function.
5 // Every OS has this file individual.
6 //
7
8 #define DebugUsbdStatusInformation( _A )
9
10 #ifndef COMMON_DEF
11 #define COMMON_DEF
12
13 #include <linux/version.h>
14 #include <linux/usb.h>
15 #include <linux/kernel.h> //need for kernel alert
16 #include <linux/autoconf.h>
17 #include <linux/sched.h>
18 #include <linux/signal.h>
19 #include <linux/slab.h> //memory allocate
20 #include <linux/module.h>
21 #include <linux/netdevice.h>
22 #include <linux/etherdevice.h>
23 #include <linux/init.h>//need for init and exit modules marco
24 #include <linux/ctype.h>
25 #include <linux/wait.h>
26 #include <linux/list.h>
27 #include <linux/wireless.h>
28 #include <linux/if_arp.h>
29 #include <asm/uaccess.h>
30 #include <net/iw_handler.h>
31 #include <linux/skbuff.h>
32
33
34 //#define DEBUG_ENABLED  1
35
36
37
38 //===============================================================
39 // Common type definition
40 //===============================================================
41
42 typedef u8*            PUCHAR;
43 typedef s8*            PCHAR;
44 typedef u8*            PBOOLEAN;
45 typedef u16*           PUSHORT;
46 typedef u32*           PULONG;
47 typedef s16*   PSHORT;
48
49
50 //===========================================
51 #define IGNORE      2
52 #define SUCCESS     1
53 #define FAILURE     0
54
55
56 #ifndef true
57 #define true        1
58 #endif
59
60 #ifndef false
61 #define false       0
62 #endif
63
64 // PD43 20021108
65 #ifndef TRUE
66 #define TRUE        1
67 #endif
68
69 #ifndef FALSE
70 #define FALSE       0
71 #endif
72
73 #define STATUS_MEDIA_CONNECT 1
74 #define STATUS_MEDIA_DISCONNECT 0
75
76 #ifndef BIT
77 #define BIT(x)                  (1 << (x))
78 #endif
79
80 typedef struct urb * PURB;
81
82
83
84 //==================================================================================================
85 // Common function definition
86 //==================================================================================================
87 #ifndef abs
88 #define abs(_T)                                                 ((_T) < 0 ? -_T : _T)
89 #endif
90 #define DEBUG_ENABLED
91 #define ETH_LENGTH_OF_ADDRESS   6
92 #ifdef DEBUG_ENABLED
93 #define WBDEBUG( _M )   printk _M
94 #else
95 #define WBDEBUG( _M )   0
96 #endif
97
98 #define OS_DISCONNECTED 0
99 #define OS_CONNECTED    1
100
101
102 #define OS_EVENT_INDICATE( _A, _B, _F )
103 #define OS_PMKID_STATUS_EVENT( _A )
104
105
106 /* Uff, no, longs are not atomic on all architectures Linux
107  * supports. This should really use atomic_t */
108
109 #define OS_ATOMIC                       u32
110 #define OS_ATOMIC_READ( _A, _V )        _V
111 #define OS_ATOMIC_INC( _A, _V )         EncapAtomicInc( _A, (void*)_V )
112 #define OS_ATOMIC_DEC( _A, _V )         EncapAtomicDec( _A, (void*)_V )
113 #define OS_MEMORY_CLEAR( _A, _S )       memset( (PUCHAR)_A,0,_S)
114 #define OS_MEMORY_COMPARE( _A, _B, _S ) (memcmp(_A,_B,_S)? 0 : 1) // Definition is reverse with Ndis 1: the same 0: different
115
116
117 #define OS_SPIN_LOCK                            spinlock_t
118 #define OS_SPIN_LOCK_ALLOCATE( _S )             spin_lock_init( _S );
119 #define OS_SPIN_LOCK_FREE( _S )
120 #define OS_SPIN_LOCK_ACQUIRED( _S )             spin_lock_irq( _S )
121 #define OS_SPIN_LOCK_RELEASED( _S )             spin_unlock_irq( _S );
122
123 #define OS_TIMER        struct timer_list
124 #define OS_TIMER_INITIAL( _T, _F, _P )                  \
125 {                                                       \
126         init_timer( _T );                               \
127         (_T)->function = (void *)_F##_1a;               \
128         (_T)->data = (unsigned long)_P;                 \
129 }
130
131 // _S : Millisecond
132 // 20060420 At least 1 large than jiffies
133 #define OS_TIMER_SET( _T, _S )                                  \
134 {                                                               \
135         (_T)->expires = jiffies + ((_S*HZ+999)/1000);\
136         add_timer( _T );                                        \
137 }
138 #define OS_TIMER_CANCEL( _T, _B )               del_timer_sync( _T )
139 #define OS_TIMER_GET_SYS_TIME( _T )             (*_T=jiffies)
140
141
142 #endif // COMMON_DEF
143