Skip to contentSkip to conversation

crc16 consolidation (common part)

PATCH New Anldrey Panin 1 participant 1 message Jan 21, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crc16 consolidation (common part)

Hi all,

currently in the linux kernel we have 5 copies of same crc16 table.

Attached patch (applies to 2.5.59 cleanly) creates common crc16 computation module, which will be used by subsequent patches for async ppp, irda and isdn subsystems.

Please consider applying.

Best regards.

Signature · 2 lines
Andrey Panin		| Embedded systems software developer
[email protected]	| PGP key: wwwkeys.pgp.net
include/linux/crc16.h +15 -0
diff -urN -X /usr/share/dontdiff linux-2.5.53.vanilla/include/linux/crc16.h linux-2.5.53/include/linux/crc16.h
@@ -0,0 +1,15 @@
+#ifndef _LINUX_CRC16_H
+#define _LINUX_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 c)
+{
+	return (crc >> 8) ^ crc16_table[(crc ^ c) & 0xff];
+}
+
+#endif /* _LINUX_CRC16_H */
lib/Kconfig +8 -0
diff -urN -X /usr/share/dontdiff linux-2.5.53.vanilla/lib/Kconfig linux-2.5.53/lib/Kconfig
@@ -4,6 +4,14 @@
 
 menu "Library routines"
 
+config CRC16
+	tristate "CRC16 functions"
+	help
+	  This option is provided for the case where no in-kernel-tree
+	  modules require CRC16 functions, but a module built outside the
+	  kernel tree does. Such modules that use library CRC16 functions
+	  require M here.
+
 config CRC32
 	tristate "CRC32 functions"
 	help
lib/Makefile +1 -0
diff -urN -X /usr/share/dontdiff linux-2.5.53.vanilla/lib/Makefile linux-2.5.53/lib/Makefile
@@ -22,6 +22,7 @@
   obj-y += dec_and_lock.o
 endif
 
+obj-$(CONFIG_CRC16)	+= crc16.o
 obj-$(CONFIG_CRC32)	+= crc32.o
 
 obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
lib/crc16.c +69 -0

69 lines not on this page · raw message

+MODULE_DESCRIPTION("CRC16 calculations");
+MODULE_LICENSE("GPL");