Merge remote-tracking branch 'regulator/fix/qcom-spmi' into regulator-linus
[sfrench/cifs-2.6.git] / arch / blackfin / include / uapi / asm / swab.h
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /*
3  * Copyright 2009 Analog Devices Inc.
4  *
5  * Licensed under the GPL-2 or later.
6  */
7
8 #ifndef _UAPI_BLACKFIN_SWAB_H
9 #define _UAPI_BLACKFIN_SWAB_H
10
11 #include <linux/types.h>
12 #include <asm-generic/swab.h>
13
14 #ifdef __GNUC__
15
16 static __inline__ __attribute_const__ __u32 __arch_swahb32(__u32 xx)
17 {
18         __u32 tmp;
19         __asm__("%1 = %0 >> 8 (V);\n\t"
20                 "%0 = %0 << 8 (V);\n\t"
21                 "%0 = %0 | %1;\n\t"
22                 : "+d"(xx), "=&d"(tmp));
23         return xx;
24 }
25 #define __arch_swahb32 __arch_swahb32
26
27 static __inline__ __attribute_const__ __u32 __arch_swahw32(__u32 xx)
28 {
29         __u32 rv;
30         __asm__("%0 = PACK(%1.L, %1.H);\n\t": "=d"(rv): "d"(xx));
31         return rv;
32 }
33 #define __arch_swahw32 __arch_swahw32
34
35 static __inline__ __attribute_const__ __u32 __arch_swab32(__u32 xx)
36 {
37         return __arch_swahb32(__arch_swahw32(xx));
38 }
39 #define __arch_swab32 __arch_swab32
40
41 static __inline__ __attribute_const__ __u16 __arch_swab16(__u16 xx)
42 {
43         __u32 xw = xx;
44         __asm__("%0 <<= 8;\n    %0.L = %0.L + %0.H (NS);\n": "+d"(xw));
45         return (__u16)xw;
46 }
47 #define __arch_swab16 __arch_swab16
48
49 #endif /* __GNUC__ */
50
51 #endif /* _UAPI_BLACKFIN_SWAB_H */