2019-06-03 12:44:46 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2005-08-17 18:17:26 +07:00
|
|
|
/*
|
|
|
|
* crc16.h - CRC-16 routine
|
|
|
|
*
|
2005-09-12 20:12:43 +07:00
|
|
|
* Implements the standard CRC-16:
|
2005-08-17 18:17:26 +07:00
|
|
|
* Width 16
|
|
|
|
* Poly 0x8005 (x^16 + x^15 + x^2 + 1)
|
|
|
|
* Init 0
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CRC16_H
|
|
|
|
#define __CRC16_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
extern u16 const crc16_table[256];
|
|
|
|
|
|
|
|
extern u16 crc16(u16 crc, const u8 *buffer, size_t len);
|
|
|
|
|
|
|
|
static inline u16 crc16_byte(u16 crc, const u8 data)
|
|
|
|
{
|
|
|
|
return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __CRC16_H */
|
|
|
|
|