spi: Use dev_get_drvdata at appropriate places
[deliverable/linux.git] / drivers / staging / csr / unifi_os.h
CommitLineData
635d2b00
GKH
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 */
36CsrResult unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size);
37void unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot);
38#define CSR_WIFI_ALIGN_BYTES 4
39CsrResult 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 */
53extern 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
635d2b00
GKH
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
8c87f69a
GKH
73void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len);
74void dump(void *mem, u16 len);
75void dump16(void *mem, u16 len);
635d2b00 76#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
8c87f69a 77void dump_str(void *mem, u16 len);
635d2b00
GKH
78#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
79
95edd09e
GKH
80void unifi_error(void* ospriv, const char *fmt, ...);
81void unifi_warning(void* ospriv, const char *fmt, ...);
82void unifi_notice(void* ospriv, const char *fmt, ...);
83void unifi_info(void* ospriv, const char *fmt, ...);
84
85void unifi_trace(void* ospriv, int level, const char *fmt, ...);
86
635d2b00
GKH
87#else
88
89/* Stubs */
635d2b00
GKH
90
91#define ASSERT(cond)
92
8c87f69a
GKH
93static inline void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len) {}
94static inline void dump(void *mem, u16 len) {}
95static inline void dump16(void *mem, u16 len) {}
635d2b00 96#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
8c87f69a 97static inline void dump_str(void *mem, u16 len) {}
635d2b00
GKH
98#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
99
95edd09e
GKH
100void unifi_error_nop(void* ospriv, const char *fmt, ...);
101void 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
635d2b00 107
95edd09e 108#endif /* UNIFI_DEBUG */
635d2b00 109
635d2b00
GKH
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.12041 seconds and 5 git commands to generate.