1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 287321fddSPaul Burton #ifndef __MIPS_ASM_BITREV_H__ 387321fddSPaul Burton #define __MIPS_ASM_BITREV_H__ 487321fddSPaul Burton 587321fddSPaul Burton #include <linux/swab.h> 687321fddSPaul Burton __arch_bitrev32(u32 x)787321fddSPaul Burtonstatic __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x) 887321fddSPaul Burton { 987321fddSPaul Burton u32 ret; 1087321fddSPaul Burton 1187321fddSPaul Burton asm("bitswap %0, %1" : "=r"(ret) : "r"(__swab32(x))); 1287321fddSPaul Burton return ret; 1387321fddSPaul Burton } 1487321fddSPaul Burton __arch_bitrev16(u16 x)1587321fddSPaul Burtonstatic __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x) 1687321fddSPaul Burton { 1787321fddSPaul Burton u16 ret; 1887321fddSPaul Burton 1987321fddSPaul Burton asm("bitswap %0, %1" : "=r"(ret) : "r"(__swab16(x))); 2087321fddSPaul Burton return ret; 2187321fddSPaul Burton } 2287321fddSPaul Burton __arch_bitrev8(u8 x)2387321fddSPaul Burtonstatic __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x) 2487321fddSPaul Burton { 2587321fddSPaul Burton u8 ret; 2687321fddSPaul Burton 2787321fddSPaul Burton asm("bitswap %0, %1" : "=r"(ret) : "r"(x)); 2887321fddSPaul Burton return ret; 2987321fddSPaul Burton } 3087321fddSPaul Burton 3187321fddSPaul Burton #endif /* __MIPS_ASM_BITREV_H__ */ 32