aboutsummaryrefslogtreecommitdiff
path: root/include/linux/crc16.h
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-04-21 19:55:38 -0400
committerTom Rini <trini@konsulko.com>2022-04-21 19:55:38 -0400
commitea5583b90f9c162af6f2025718dc50ffbb6e4552 (patch)
tree91f01f0434711bb9c31a311c0ba0e876c9627a8f /include/linux/crc16.h
parente50f66e364be80e02dd0834b84b830f3aade82ea (diff)
parent151a030063898e5c8b03b40c3a96b073db0b0dc7 (diff)
Merge branch '2022-04-21-further-cleanups'
- Fix SPL_SYS_MALLOC_SIMPLE and non-SPL_FRAMEWORK boards (a large number of PowerPC platforms) - Remove duplication of crc16 functionality - Migrate COUNTER_FREQUENCY to CONFIG_COUNTER_FREQUENCY and have it in Kconfig
Diffstat (limited to 'include/linux/crc16.h')
-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 0000000000..052fd3311a
--- /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 */