diff options
author | Bin Meng <bmeng.cn@gmail.com> | 2018-08-02 23:58:02 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-09-18 00:01:18 -0600 |
commit | 9c2cb97e22a7a12bf87d0af7e90156afe7a78d21 (patch) | |
tree | f400d4bf100af43a1c95c5c3f6debedb5d6ae9aa /lib | |
parent | e599c4e7d8e1bd6e923838a77d01271935709cfd (diff) | |
download | u-boot-9c2cb97e22a7a12bf87d0af7e90156afe7a78d21.tar.gz u-boot-9c2cb97e22a7a12bf87d0af7e90156afe7a78d21.tar.bz2 u-boot-9c2cb97e22a7a12bf87d0af7e90156afe7a78d21.zip |
lib: bitrev: Sync with Linux kernel v4.17
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bitrev.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/bitrev.c b/lib/bitrev.c index 4d494e1733..08231c056c 100644 --- a/lib/bitrev.c +++ b/lib/bitrev.c @@ -1,13 +1,14 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * - * Based on bitrev from the Linux kernel, by Akinobu Mita - */ - +// SPDX-License-Identifier: GPL-2.0 +#ifndef CONFIG_HAVE_ARCH_BITREVERSE #include <linux/types.h> +#include <linux/compat.h> #include <linux/bitrev.h> +MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>"); +MODULE_DESCRIPTION("Bit ordering reversal functions"); +MODULE_LICENSE("GPL"); + const u8 byte_rev_table[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, @@ -42,17 +43,6 @@ const u8 byte_rev_table[256] = { 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, }; +EXPORT_SYMBOL_GPL(byte_rev_table); -u16 bitrev16(u16 x) -{ - return (bitrev8(x & 0xff) << 8) | bitrev8(x >> 8); -} - -/** - * bitrev32 - reverse the order of bits in a u32 value - * @x: value to be bit-reversed - */ -u32 bitrev32(u32 x) -{ - return (bitrev16(x & 0xffff) << 16) | bitrev16(x >> 16); -} +#endif /* CONFIG_HAVE_ARCH_BITREVERSE */ |