xref: /linux/arch/arm/include/asm/bitrev.h (revision 0b7857dbeb256d1a9c0c606ec4b5f417e159040b)
1*0b7857dbSYalin Wang #ifndef __ASM_BITREV_H
2*0b7857dbSYalin Wang #define __ASM_BITREV_H
3*0b7857dbSYalin Wang 
4*0b7857dbSYalin Wang static __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x)
5*0b7857dbSYalin Wang {
6*0b7857dbSYalin Wang 	__asm__ ("rbit %0, %1" : "=r" (x) : "r" (x));
7*0b7857dbSYalin Wang 	return x;
8*0b7857dbSYalin Wang }
9*0b7857dbSYalin Wang 
10*0b7857dbSYalin Wang static __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x)
11*0b7857dbSYalin Wang {
12*0b7857dbSYalin Wang 	return __arch_bitrev32((u32)x) >> 16;
13*0b7857dbSYalin Wang }
14*0b7857dbSYalin Wang 
15*0b7857dbSYalin Wang static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x)
16*0b7857dbSYalin Wang {
17*0b7857dbSYalin Wang 	return __arch_bitrev32((u32)x) >> 24;
18*0b7857dbSYalin Wang }
19*0b7857dbSYalin Wang 
20*0b7857dbSYalin Wang #endif
21