Skip to contentSkip to conversation

lib/crc-ccitt: add CCITT-FALSE CRC16 variant

PATCH Applied Andrey Smirnov 3 participants 4 messages Apr 13, 2017

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

PATCH 1/1 lib/crc-ccitt: add CCITT-FALSE CRC16 variant

From: Andrey Vostrikov <[email protected]>

---
 include/linux/crc-ccitt.h |  7 ++++++
 lib/crc-ccitt.c           | 58 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 1 deletion(-)
include/linux/crc-ccitt.h +7 -0
index f52696a..7cd45a4 100644
@@ -4,12 +4,19 @@
 #include <linux/types.h>
 
 extern u16 const crc_ccitt_table[256];
+extern u16 const crc_ccitt_false_table[256];
 
 extern u16 crc_ccitt(u16 crc, const u8 *buffer, size_t len);
+extern u16 crc_ccitt_false(u16 crc, const u8 *buffer, size_t len);
 
 static inline u16 crc_ccitt_byte(u16 crc, const u8 c)
 {
 	return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff];
 }
 
+static inline u16 crc_ccitt_false_byte(u16 crc, const u8 c)
+{
+    return (crc << 8) ^ crc_ccitt_false_table[(crc >> 8) ^ c];
+}
+
 #endif /* _LINUX_CRC_CCITT_H */
lib/crc-ccitt.c +57 -1

70 lines not on this page · raw message

Signature · 1 line
2.9.3
Tested-by on v1 1/1
#2 lore raw
In reply to Andrey Smirnov
Quoted 11 lines · Andrey Smirnov

From: Andrey Vostrikov <[email protected]>

---
 include/linux/crc-ccitt.h |  7 ++++++
 lib/crc-ccitt.c           | 58 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 1 deletion(-)

In support of a soon to be published MFD driver using serdev to talk to a supervisory processor that uses the CCITT-FALSE CRC16 variant in it's protocol, this patch was tested successfully on an i.MX6 ARM platform.

maintainer Acked-by
#3 lore raw
Quoted 14 lines · On Thu, 13 Apr 2017 13:09:37 -0700 Chris Healy <[email protected]> wrote:
Quoted 11 lines · Andrey Smirnov

From: Andrey Vostrikov <[email protected]>

---
 include/linux/crc-ccitt.h |  7 ++++++
 lib/crc-ccitt.c           | 58 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 1 deletion(-)
Quoted 6 lines

In support of a soon to be published MFD driver using serdev to talk to a supervisory processor that uses the CCITT-FALSE CRC16 variant in it's protocol, this patch was tested successfully on an i.MX6 ARM platform.

OK. Please add the above text to the changelog and include this patch in whatever tree adds the new driver.