1 // SPDX-License-Identifier: GPL-2.0-only 1 2 /* 3 * linux/lib/crc-ccitt.c 4 */ 5 6 #include <linux/types.h> 7 #include <linux/module.h> 8 #include <linux/crc-ccitt.h> 9 10 /* 11 * This mysterious table is just the CRC of ea 12 * computed using the standard bit-at-a-time m 13 * be seen in entry 128, 0x8408. This correspo 14 * Add the implicit x^16, and you have the sta 15 */ 16 u16 const crc_ccitt_table[256] = { 17 0x0000, 0x1189, 0x2312, 0x329b, 0x4624 18 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c 19 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5 20 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed 21 0x2102, 0x308b, 0x0210, 0x1399, 0x6726 22 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e 23 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7 24 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef 25 0x4204, 0x538d, 0x6116, 0x709f, 0x0420 26 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868 27 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1 28 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9 29 0x6306, 0x728f, 0x4014, 0x519d, 0x2522 30 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a 31 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3 32 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb 33 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c 34 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64 35 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad 36 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5 37 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e 38 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66 39 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af 40 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7 41 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028 42 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60 43 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9 44 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1 45 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a 46 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62 47 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab 48 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3 49 }; 50 EXPORT_SYMBOL(crc_ccitt_table); 51 52 /** 53 * crc_ccitt - recompute the CRC (CRC-CCI 54 * buffer 55 * @crc: previous CRC value 56 * @buffer: data pointer 57 * @len: number of bytes in the buffer 58 */ 59 u16 crc_ccitt(u16 crc, u8 const *buffer, size_ 60 { 61 while (len--) 62 crc = crc_ccitt_byte(crc, *buf 63 return crc; 64 } 65 EXPORT_SYMBOL(crc_ccitt); 66 67 MODULE_DESCRIPTION("CRC-CCITT calculations"); 68 MODULE_LICENSE("GPL"); 69
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.