summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2022-04-12 11:20:41 +0200
committerTom Rini <trini@konsulko.com>2022-04-21 14:32:40 -0400
commite523f5d181ce66a36b5f9476b86be2fa03284a45 (patch)
treeaff5f216aaef505eb5d409f59e53a77e7be313cc /include/linux
parentbb3d71b7eff4f137c1c4560950536aeb1740e004 (diff)
crc16: Rename fs/ubifs/crc16.h to include/linux/crc16.h
File fs/ubifs/crc16.h is standard linux's crc16.h include file. So move it from fs/ubifs to include/linux where are also other linux include files. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/crc16.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/linux/crc16.h b/include/linux/crc16.h
new file mode 100644
index 00000000000..052fd3311a9
--- /dev/null
+++ b/include/linux/crc16.h
@@ -0,0 +1,29 @@
+/*
+ * crc16.h - CRC-16 routine
+ *
+ * Implements the standard CRC-16:
+ * Width 16
+ * Poly 0x8005 (x^16 + x^15 + x^2 + 1)
+ * Init 0
+ *
+ * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2. See the file COPYING for more details.
+ */
+
+#ifndef __CRC16_H
+#define __CRC16_H
+
+#include <linux/types.h>
+
+extern u16 const crc16_table[256];
+
+extern u16 crc16(u16 crc, const u8 *buffer, size_t len);
+
+static inline u16 crc16_byte(u16 crc, const u8 data)
+{
+ return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
+}
+
+#endif /* __CRC16_H */