| Evgeniy Polyakov | 7657ec1 | 2005-08-17 15:17:26 +0400 | [diff] [blame] | 1 | /* | 
|  | 2 | *	crc16.h - CRC-16 routine | 
|  | 3 | * | 
| Evgeniy Polyakov | f24ec7f | 2005-09-12 17:12:43 +0400 | [diff] [blame] | 4 | * Implements the standard CRC-16: | 
| Evgeniy Polyakov | 7657ec1 | 2005-08-17 15:17:26 +0400 | [diff] [blame] | 5 | *   Width 16 | 
|  | 6 | *   Poly  0x8005 (x^16 + x^15 + x^2 + 1) | 
|  | 7 | *   Init  0 | 
|  | 8 | * | 
| Evgeniy Polyakov | 7657ec1 | 2005-08-17 15:17:26 +0400 | [diff] [blame] | 9 | * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com> | 
|  | 10 | * | 
|  | 11 | * This source code is licensed under the GNU General Public License, | 
|  | 12 | * Version 2. See the file COPYING for more details. | 
|  | 13 | */ | 
|  | 14 |  | 
|  | 15 | #ifndef __CRC16_H | 
|  | 16 | #define __CRC16_H | 
|  | 17 |  | 
|  | 18 | #include <linux/types.h> | 
|  | 19 |  | 
| Evgeniy Polyakov | 7657ec1 | 2005-08-17 15:17:26 +0400 | [diff] [blame] | 20 | extern u16 const crc16_table[256]; | 
|  | 21 |  | 
|  | 22 | extern u16 crc16(u16 crc, const u8 *buffer, size_t len); | 
|  | 23 |  | 
|  | 24 | static inline u16 crc16_byte(u16 crc, const u8 data) | 
|  | 25 | { | 
|  | 26 | return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff]; | 
|  | 27 | } | 
|  | 28 |  | 
|  | 29 | #endif /* __CRC16_H */ | 
|  | 30 |  |