[U-Boot] [PATCH 6/8] lib: import bitrev library from linux kernel

Marek Vasut
2013-04-08T06:23:56Z

Dear Mike Dunn,

> This patch adds the bitrev library from the linux kernel. This is a simple
> algorithm that uses an 8 bit look-up table to reverse the bits in data
> types of 8, 16, or 32 bit widths. The docg4 nand flash driver uses it.
>
> Signed-off-by: Mike Dunn <mikedunn@newsguy.com>
> ---
> include/linux/bitrev.h | 16 +++++++++++++
> lib/Makefile | 1 +
> lib/bitrev.c | 56
> ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73
> insertions(+), 0 deletions(-)
> create mode 100644 include/linux/bitrev.h
> create mode 100644 lib/bitrev.c
>
> diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
> new file mode 100644
> index 0000000..7ffe03f
> --- /dev/null
> +++ b/include/linux/bitrev.h
> @@ -0,0 +1,16 @@
> +#ifndef _LINUX_BITREV_H
> +#define _LINUX_BITREV_H
> +
> +#include <linux/types.h>
> +
> +extern u8 const byte_rev_table[256];
> +
> +static inline u8 bitrev8(u8 byte)
> +{
> + return byte_rev_table[byte];
> +}
> +
> +extern u16 bitrev16(u16 in);
> +extern u32 bitrev32(u32 in);

Do we really need to expose the array and use so many externs here? …