aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2022-04-12 11:20:42 +0200
committerTom Rini <trini@konsulko.com>2022-04-21 14:32:40 -0400
commit1a47e6d47c7184b116bb58e8451dc0d4f141a609 (patch)
treebe4f127bc92f771a0c5254083fec1562453d8e1c
parente523f5d181ce66a36b5f9476b86be2fa03284a45 (diff)
downloadu-boot-1a47e6d47c7184b116bb58e8451dc0d4f141a609.zip
u-boot-1a47e6d47c7184b116bb58e8451dc0d4f141a609.tar.gz
u-boot-1a47e6d47c7184b116bb58e8451dc0d4f141a609.tar.bz2
crc16: Move standard CRC-16 implementation from ubifs to lib
This implementation provides standard CRC-16 algorithm with polynomial x^16 + x^15 + x^2 + 1. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de>
-rw-r--r--fs/ubifs/Makefile2
-rw-r--r--include/u-boot/crc.h3
-rw-r--r--lib/Makefile1
-rw-r--r--lib/crc16.c (renamed from fs/ubifs/crc16.c)0
4 files changed, 5 insertions, 1 deletions
diff --git a/fs/ubifs/Makefile b/fs/ubifs/Makefile
index 64d6447..631ba5f 100644
--- a/fs/ubifs/Makefile
+++ b/fs/ubifs/Makefile
@@ -9,5 +9,5 @@
obj-y := ubifs.o io.o super.o sb.o master.o lpt.o
obj-y += lpt_commit.o scan.o lprops.o
-obj-y += tnc.o tnc_misc.o debug.o crc16.o budget.o
+obj-y += tnc.o tnc_misc.o debug.o budget.o
obj-y += log.o orphan.o recovery.o replay.o gc.o
diff --git a/include/u-boot/crc.h b/include/u-boot/crc.h
index eba8edf..5174bd7 100644
--- a/include/u-boot/crc.h
+++ b/include/u-boot/crc.h
@@ -25,6 +25,9 @@
*/
unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len);
+/* lib/crc16.c - 16 bit CRC with polynomial x^16 + x^15 + x^2 + 1 */
+uint16_t crc16(uint16_t crc, const unsigned char *buffer, size_t len);
+
/* lib/crc16-ccitt.c - 16 bit CRC with polynomial x^16+x^12+x^5+1 (CRC-CCITT) */
uint16_t crc16_ccitt(uint16_t crc_start, const unsigned char *s, int len);
/**
diff --git a/lib/Makefile b/lib/Makefile
index cf662a7..d9b1811 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_CIRCBUF) += circbuf.o
endif
obj-y += crc8.o
+obj-y += crc16.o
obj-y += crc16-ccitt.o
obj-$(CONFIG_ERRNO_STR) += errno_str.o
obj-$(CONFIG_FIT) += fdtdec_common.o
diff --git a/fs/ubifs/crc16.c b/lib/crc16.c
index 7cf33fc..7cf33fc 100644
--- a/fs/ubifs/crc16.c
+++ b/lib/crc16.c