Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  crc16.h - CRC-16 routine
0004  *
0005  * Implements the standard CRC-16:
0006  *   Width 16
0007  *   Poly  0x8005 (x^16 + x^15 + x^2 + 1)
0008  *   Init  0
0009  *
0010  * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
0011  */
0012 
0013 #ifndef __CRC16_H
0014 #define __CRC16_H
0015 
0016 #include <linux/types.h>
0017 
0018 extern u16 const crc16_table[256];
0019 
0020 extern u16 crc16(u16 crc, const u8 *buffer, size_t len);
0021 
0022 static inline u16 crc16_byte(u16 crc, const u8 data)
0023 {
0024     return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
0025 }
0026 
0027 #endif /* __CRC16_H */
0028