Merge branch 'drm-nouveau-fixes-3.9' of git://anongit.freedesktop.org/git/nouveau...
[deliverable/linux.git] / drivers / staging / csr / unifi_os.h
1 /*
2 * ---------------------------------------------------------------------------
3 *
4 * FILE: os_linux/unifi_os.h
5 *
6 * PURPOSE:
7 * This header file provides the OS-dependent facilities for a linux
8 * environment.
9 *
10 * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 * ---------------------------------------------------------------------------
16 */
17 #ifndef __UNIFI_OS_LINUX_H__
18 #define __UNIFI_OS_LINUX_H__ 1
19
20 #include <linux/kernel.h>
21 #include <linux/time.h>
22 #include <linux/list.h>
23 #include <linux/delay.h>
24 #include <linux/string.h>
25
26 /*
27 * Needed for core/signals.c
28 */
29 #include <stddef.h>
30
31
32 /* Define INLINE directive*/
33 #define INLINE inline
34
35 /* Malloc and free */
36 CsrResult unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size);
37 void unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot);
38 #define CSR_WIFI_ALIGN_BYTES 4
39 CsrResult unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot);
40
41 /*
42 * Byte Order
43 * Note that __le*_to_cpu and __cpu_to_le* return an unsigned value!
44 */
45 #ifdef __KERNEL__
46 #define unifi2host_16(n) (__le16_to_cpu((n)))
47 #define unifi2host_32(n) (__le32_to_cpu((n)))
48 #define host2unifi_16(n) (__cpu_to_le16((n)))
49 #define host2unifi_32(n) (__cpu_to_le32((n)))
50 #endif
51
52 /* Module parameters */
53 extern int unifi_debug;
54
55 /* debugging */
56 #ifdef UNIFI_DEBUG
57 /*
58 * unifi_debug is a verbosity level for debug messages
59 * UDBG0 msgs are always printed if UNIFI_DEBUG is defined
60 * UDBG1 msgs are printed if UNIFI_DEBUG is defined and unifi_debug > 0
61 * etc.
62 */
63
64 #define ASSERT(cond) \
65 do { \
66 if (!(cond)) { \
67 printk("Assertion failed in %s at %s:%d: %s\n", \
68 __FUNCTION__, __FILE__, __LINE__, #cond); \
69 } \
70 } while (0)
71
72
73 void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len);
74 void dump(void *mem, u16 len);
75 void dump16(void *mem, u16 len);
76 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
77 void dump_str(void *mem, u16 len);
78 #endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
79
80 void unifi_error(void* ospriv, const char *fmt, ...);
81 void unifi_warning(void* ospriv, const char *fmt, ...);
82 void unifi_notice(void* ospriv, const char *fmt, ...);
83 void unifi_info(void* ospriv, const char *fmt, ...);
84
85 void unifi_trace(void* ospriv, int level, const char *fmt, ...);
86
87 #else
88
89 /* Stubs */
90
91 #define ASSERT(cond)
92
93 static inline void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len) {}
94 static inline void dump(void *mem, u16 len) {}
95 static inline void dump16(void *mem, u16 len) {}
96 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
97 static inline void dump_str(void *mem, u16 len) {}
98 #endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
99
100 void unifi_error_nop(void* ospriv, const char *fmt, ...);
101 void unifi_trace_nop(void* ospriv, int level, const char *fmt, ...);
102 #define unifi_error if(1);else unifi_error_nop
103 #define unifi_warning if(1);else unifi_error_nop
104 #define unifi_notice if(1);else unifi_error_nop
105 #define unifi_info if(1);else unifi_error_nop
106 #define unifi_trace if(1);else unifi_trace_nop
107
108 #endif /* UNIFI_DEBUG */
109
110
111 /* Different levels of diagnostic detail... */
112 #define UDBG0 0 /* always prints in debug build */
113 #define UDBG1 1
114 #define UDBG2 2
115 #define UDBG3 3
116 #define UDBG4 4
117 #define UDBG5 5
118 #define UDBG6 6
119 #define UDBG7 7
120
121
122 #endif /* __UNIFI_OS_LINUX_H__ */
This page took 0.032906 seconds and 5 git commands to generate.