diff options
author | Rabin Vincent <rabin@rab.in> | 2009-10-25 11:55:33 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-10-25 11:59:53 -0400 |
commit | 40f5b07832ce29e66f42b61a2e9a1fd94783c136 (patch) | |
tree | ae197b0653a565754e741e505c826773d6a2353f /arch/arm/include/asm/swab.h | |
parent | a8cf81ffe0284660fe405e7189f47f1b032f5261 (diff) |
ARM: 5772/1: Use REV and REV16 for byte swapping on ARMv6+
ARMv6 introduced the REV and REV16 instructions that reverse bytes in
words and halfwords. Use them for the arch-specific implementation of
the byte swapping helpers on ARMv6+.
Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include/asm/swab.h')
-rw-r--r-- | arch/arm/include/asm/swab.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/arm/include/asm/swab.h b/arch/arm/include/asm/swab.h index ca2bf2f6d6ea..9997ad20eff1 100644 --- a/arch/arm/include/asm/swab.h +++ b/arch/arm/include/asm/swab.h | |||
@@ -22,6 +22,24 @@ | |||
22 | # define __SWAB_64_THRU_32__ | 22 | # define __SWAB_64_THRU_32__ |
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | #if defined(__KERNEL__) && __LINUX_ARM_ARCH__ >= 6 | ||
26 | |||
27 | static inline __attribute_const__ __u16 __arch_swab16(__u16 x) | ||
28 | { | ||
29 | __asm__ ("rev16 %0, %1" : "=r" (x) : "r" (x)); | ||
30 | return x; | ||
31 | } | ||
32 | #define __arch_swab16 __arch_swab16 | ||
33 | |||
34 | static inline __attribute_const__ __u32 __arch_swab32(__u32 x) | ||
35 | { | ||
36 | __asm__ ("rev %0, %1" : "=r" (x) : "r" (x)); | ||
37 | return x; | ||
38 | } | ||
39 | #define __arch_swab32 __arch_swab32 | ||
40 | |||
41 | #else | ||
42 | |||
25 | static inline __attribute_const__ __u32 __arch_swab32(__u32 x) | 43 | static inline __attribute_const__ __u32 __arch_swab32(__u32 x) |
26 | { | 44 | { |
27 | __u32 t; | 45 | __u32 t; |
@@ -48,3 +66,4 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x) | |||
48 | 66 | ||
49 | #endif | 67 | #endif |
50 | 68 | ||
69 | #endif | ||