blob: 9fa74529b31787ba2434326d9ff02913c8cdf740 [file] [log] [blame]
Thomas Gleixner40b0b3f2019-06-03 07:44:46 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Evgeniy Polyakov7657ec12005-08-17 15:17:26 +04002/*
3 * crc16.h - CRC-16 routine
4 *
Evgeniy Polyakovf24ec7f2005-09-12 17:12:43 +04005 * Implements the standard CRC-16:
Evgeniy Polyakov7657ec12005-08-17 15:17:26 +04006 * Width 16
7 * Poly 0x8005 (x^16 + x^15 + x^2 + 1)
8 * Init 0
9 *
Evgeniy Polyakov7657ec12005-08-17 15:17:26 +040010 * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
Evgeniy Polyakov7657ec12005-08-17 15:17:26 +040011 */
12
13#ifndef __CRC16_H
14#define __CRC16_H
15
16#include <linux/types.h>
17
Evgeniy Polyakov7657ec12005-08-17 15:17:26 +040018extern u16 const crc16_table[256];
19
20extern u16 crc16(u16 crc, const u8 *buffer, size_t len);
21
22static inline u16 crc16_byte(u16 crc, const u8 data)
23{
24 return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
25}
26
27#endif /* __CRC16_H */
28