Merge branch 'gpio/next' of git://git.secretlab.ca/git/linux-2.6
[pandora-kernel.git] / drivers / staging / rtl8712 / generic.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  * Modifications for inclusion into the Linux staging tree are
19  * Copyright(c) 2010 Larry Finger. All rights reserved.
20  *
21  * Contact information:
22  * WLAN FAE <wlanfae@realtek.com>
23  * Larry Finger <Larry.Finger@lwfinger.net>
24  *
25  ******************************************************************************/
26 #ifndef _LINUX_BYTEORDER_GENERIC_H
27 #define _LINUX_BYTEORDER_GENERIC_H
28
29 /*
30  * linux/byteorder_generic.h
31  * Generic Byte-reordering support
32  *
33  * Francois-Rene Rideau <fare@tunes.org> 19970707
34  *    gathered all the good ideas from all asm-foo/byteorder.h into one file,
35  *    cleaned them up.
36  *    I hope it is compliant with non-GCC compilers.
37  *    I decided to put __BYTEORDER_HAS_U64__ in byteorder.h,
38  *    because I wasn't sure it would be ok to put it in types.h
39  *    Upgraded it to 2.1.43
40  * Francois-Rene Rideau <fare@tunes.org> 19971012
41  *    Upgraded it to 2.1.57
42  *    to please Linus T., replaced huge #ifdef's between little/big endian
43  *    by nestedly #include'd files.
44  * Francois-Rene Rideau <fare@tunes.org> 19971205
45  *    Made it to 2.1.71; now a facelift:
46  *    Put files under include/linux/byteorder/
47  *    Split swab from generic support.
48  *
49  * TODO:
50  *   = Regular kernel maintainers could also replace all these manual
51  *    byteswap macros that remain, disseminated among drivers,
52  *    after some grep or the sources...
53  *   = Linus might want to rename all these macros and files to fit his taste,
54  *    to fit his personal naming scheme.
55  *   = it seems that a few drivers would also appreciate
56  *    nybble swapping support...
57  *   = every architecture could add their byteswap macro in asm/byteorder.h
58  *    see how some architectures already do (i386, alpha, ppc, etc)
59  *   = cpu_to_beXX and beXX_to_cpu might some day need to be well
60  *    distinguished throughout the kernel. This is not the case currently,
61  *    since little endian, big endian, and pdp endian machines needn't it.
62  *    But this might be the case for, say, a port of Linux to 20/21 bit
63  *    architectures (and F21 Linux addict around?).
64  */
65
66 /*
67  * The following macros are to be defined by <asm/byteorder.h>:
68  *
69  * Conversion of long and short int between network and host format
70  *      ntohl(__u32 x)
71  *      ntohs(__u16 x)
72  *      htonl(__u32 x)
73  *      htons(__u16 x)
74  * It seems that some programs (which? where? or perhaps a standard? POSIX?)
75  * might like the above to be functions, not macros (why?).
76  * if that's true, then detect them, and take measures.
77  * Anyway, the measure is: define only ___ntohl as a macro instead,
78  * and in a separate file, have
79  * unsigned long inline ntohl(x){return ___ntohl(x);}
80  *
81  * The same for constant arguments
82  *      __constant_ntohl(__u32 x)
83  *      __constant_ntohs(__u16 x)
84  *      __constant_htonl(__u32 x)
85  *      __constant_htons(__u16 x)
86  *
87  * Conversion of XX-bit integers (16- 32- or 64-)
88  * between native CPU format and little/big endian format
89  * 64-bit stuff only defined for proper architectures
90  *      cpu_to_[bl]eXX(__uXX x)
91  *      [bl]eXX_to_cpu(__uXX x)
92  *
93  * The same, but takes a pointer to the value to convert
94  *      cpu_to_[bl]eXXp(__uXX x)
95  *      [bl]eXX_to_cpup(__uXX x)
96  *
97  * The same, but change in situ
98  *      cpu_to_[bl]eXXs(__uXX x)
99  *      [bl]eXX_to_cpus(__uXX x)
100  *
101  * See asm-foo/byteorder.h for examples of how to provide
102  * architecture-optimized versions
103  *
104  */
105
106
107 /*
108  * inside the kernel, we can use nicknames;
109  * outside of it, we must avoid POSIX namespace pollution...
110  */
111 #define cpu_to_le64 __cpu_to_le64
112 #define le64_to_cpu __le64_to_cpu
113 #define cpu_to_le32 __cpu_to_le32
114 #define le32_to_cpu __le32_to_cpu
115 #define cpu_to_le16 __cpu_to_le16
116 #define le16_to_cpu __le16_to_cpu
117 #define cpu_to_be64 __cpu_to_be64
118 #define be64_to_cpu __be64_to_cpu
119 #define cpu_to_be32 __cpu_to_be32
120 #define be32_to_cpu __be32_to_cpu
121 #define cpu_to_be16 __cpu_to_be16
122 #define be16_to_cpu __be16_to_cpu
123 #define cpu_to_le64p __cpu_to_le64p
124 #define le64_to_cpup __le64_to_cpup
125 #define cpu_to_le32p __cpu_to_le32p
126 #define le32_to_cpup __le32_to_cpup
127 #define cpu_to_le16p __cpu_to_le16p
128 #define le16_to_cpup __le16_to_cpup
129 #define cpu_to_be64p __cpu_to_be64p
130 #define be64_to_cpup __be64_to_cpup
131 #define cpu_to_be32p __cpu_to_be32p
132 #define be32_to_cpup __be32_to_cpup
133 #define cpu_to_be16p __cpu_to_be16p
134 #define be16_to_cpup __be16_to_cpup
135 #define cpu_to_le64s __cpu_to_le64s
136 #define le64_to_cpus __le64_to_cpus
137 #define cpu_to_le32s __cpu_to_le32s
138 #define le32_to_cpus __le32_to_cpus
139 #define cpu_to_le16s __cpu_to_le16s
140 #define le16_to_cpus __le16_to_cpus
141 #define cpu_to_be64s __cpu_to_be64s
142 #define be64_to_cpus __be64_to_cpus
143 #define cpu_to_be32s __cpu_to_be32s
144 #define be32_to_cpus __be32_to_cpus
145 #define cpu_to_be16s __cpu_to_be16s
146 #define be16_to_cpus __be16_to_cpus
147
148
149 /*
150  * Handle ntohl and suches. These have various compatibility
151  * issues - like we want to give the prototype even though we
152  * also have a macro for them in case some strange program
153  * wants to take the address of the thing or something..
154  *
155  * Note that these used to return a "long" in libc5, even though
156  * long is often 64-bit these days.. Thus the casts.
157  *
158  * They have to be macros in order to do the constant folding
159  * correctly - if the argument passed into a inline function
160  * it is no longer constant according to gcc..
161  */
162
163 #undef ntohl
164 #undef ntohs
165 #undef htonl
166 #undef htons
167
168 /*
169  * Do the prototypes. Somebody might want to take the
170  * address or some such sick thing..
171  */
172 extern __u32                    ntohl(__u32);
173 extern __u32                    htonl(__u32);
174 extern unsigned short int       ntohs(unsigned short int);
175 extern unsigned short int       htons(unsigned short int);
176
177 #endif /* _LINUX_BYTEORDER_GENERIC_H */
178