Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  crc-itu-t.h - CRC ITU-T V.41 routine
0004  *
0005  * Implements the standard CRC ITU-T V.41:
0006  *   Width 16
0007  *   Poly  0x1021 (x^16 + x^12 + x^5 + 1)
0008  *   Init  0
0009  */
0010 
0011 #ifndef CRC_ITU_T_H
0012 #define CRC_ITU_T_H
0013 
0014 #include <linux/types.h>
0015 
0016 extern u16 const crc_itu_t_table[256];
0017 
0018 extern u16 crc_itu_t(u16 crc, const u8 *buffer, size_t len);
0019 
0020 static inline u16 crc_itu_t_byte(u16 crc, const u8 data)
0021 {
0022     return (crc << 8) ^ crc_itu_t_table[((crc >> 8) ^ data) & 0xff];
0023 }
0024 
0025 #endif /* CRC_ITU_T_H */
0026