mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
lib/crc-ccitt: Add CCITT-FALSE CRC16 variant
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. Link: http://lkml.kernel.org/r/20170413142932.27287-1-andrew.smirnov@gmail.com Signed-off-by: Andrey Vostrikov <andrey.vostrikov@cogentembedded.com> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Tested-by: Chris Healy <cphealy@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
4fbd8d194f
commit
0d85adb5fb
2 changed files with 64 additions and 1 deletions
|
@ -5,12 +5,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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue