1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 20b7857dbSYalin Wang #ifndef __ASM_BITREV_H 30b7857dbSYalin Wang #define __ASM_BITREV_H 40b7857dbSYalin Wang __arch_bitrev32(u32 x)50b7857dbSYalin Wangstatic __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x) 60b7857dbSYalin Wang { 70b7857dbSYalin Wang __asm__ ("rbit %0, %1" : "=r" (x) : "r" (x)); 80b7857dbSYalin Wang return x; 90b7857dbSYalin Wang } 100b7857dbSYalin Wang __arch_bitrev16(u16 x)110b7857dbSYalin Wangstatic __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x) 120b7857dbSYalin Wang { 130b7857dbSYalin Wang return __arch_bitrev32((u32)x) >> 16; 140b7857dbSYalin Wang } 150b7857dbSYalin Wang __arch_bitrev8(u8 x)160b7857dbSYalin Wangstatic __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x) 170b7857dbSYalin Wang { 180b7857dbSYalin Wang return __arch_bitrev32((u32)x) >> 24; 190b7857dbSYalin Wang } 200b7857dbSYalin Wang 210b7857dbSYalin Wang #endif 22