Merge branch 'fix/soundcore' into for-linus
[pandora-kernel.git] / arch / blackfin / include / asm / swab.h
1 #ifndef _BLACKFIN_SWAB_H
2 #define _BLACKFIN_SWAB_H
3
4 #include <linux/types.h>
5 #include <asm-generic/swab.h>
6
7 #ifdef __GNUC__
8
9 static __inline__ __attribute_const__ __u32 __arch_swahb32(__u32 xx)
10 {
11         __u32 tmp;
12         __asm__("%1 = %0 >> 8 (V);\n\t"
13                 "%0 = %0 << 8 (V);\n\t"
14                 "%0 = %0 | %1;\n\t"
15                 : "+d"(xx), "=&d"(tmp));
16         return xx;
17 }
18 #define __arch_swahb32 __arch_swahb32
19
20 static __inline__ __attribute_const__ __u32 __arch_swahw32(__u32 xx)
21 {
22         __u32 rv;
23         __asm__("%0 = PACK(%1.L, %1.H);\n\t": "=d"(rv): "d"(xx));
24         return rv;
25 }
26 #define __arch_swahw32 __arch_swahw32
27
28 static __inline__ __attribute_const__ __u32 __arch_swab32(__u32 xx)
29 {
30         return __arch_swahb32(__arch_swahw32(xx));
31 }
32 #define __arch_swab32 __arch_swab32
33
34 static __inline__ __attribute_const__ __u16 __arch_swab16(__u16 xx)
35 {
36         __u32 xw = xx;
37         __asm__("%0 <<= 8;\n    %0.L = %0.L + %0.H (NS);\n": "+d"(xw));
38         return (__u16)xw;
39 }
40 #define __arch_swab16 __arch_swab16
41
42 #endif /* __GNUC__ */
43
44 #endif                          /* _BLACKFIN_SWAB_H */