Skip to contentSkip to conversation

consolidate crc16 calculations (common part)

PATCH New Andrey Panin 1 participant 1 message Mar 12, 2003

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

PATCH 1/1 consolidate crc16 calculations (common part)

Hi,

yet another resend of crc16 patched is started :)

Attached patch (2.5.64) creates crc16.c module. It will be used by 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
lib/Kconfig +8 -0
diff -urN -X /usr/share/dontdiff linux-2.5.64.vanilla/lib/Kconfig linux-2.5.64/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.64.vanilla/lib/Makefile linux-2.5.64/lib/Makefile
@@ -19,6 +19,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 +72 -0

72 lines not on this page · raw message

include/linux/crc16.h +15 -0
diff -urN -X /usr/share/dontdiff linux-2.5.64.vanilla/include/linux/crc16.h linux-2.5.64/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 */