mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-06-21 15:43:21 +02:00
83aede8131
Define generic___bitrev8/16/32 using the implementation in <linux/bitrev.h>, so they can be reused in <asm/bitrev.h>, such as RISCV. Reviewed-by: Yury Norov <ynorov@nvidia.com> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Signed-off-by: Yury Norov <ynorov@nvidia.com>
24 lines
640 B
C
24 lines
640 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_GENERIC_BITOPS___BITREV_H_
|
|
#define _ASM_GENERIC_BITOPS___BITREV_H_
|
|
|
|
#include <asm/types.h>
|
|
|
|
extern u8 const byte_rev_table[256];
|
|
static __always_inline __attribute_const__ u8 generic___bitrev8(u8 byte)
|
|
{
|
|
return byte_rev_table[byte];
|
|
}
|
|
|
|
static __always_inline __attribute_const__ u16 generic___bitrev16(u16 x)
|
|
{
|
|
return (generic___bitrev8(x & 0xff) << 8) | generic___bitrev8(x >> 8);
|
|
}
|
|
|
|
static __always_inline __attribute_const__ u32 generic___bitrev32(u32 x)
|
|
{
|
|
return (generic___bitrev16(x & 0xffff) << 16) | generic___bitrev16(x >> 16);
|
|
}
|
|
|
|
#endif /* _ASM_GENERIC_BITOPS___BITREV_H_ */
|