File: crc16.h

package info (click to toggle)
linux 3.16.7-ckt2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 734,120 kB
  • ctags: 2,369,605
  • sloc: ansic: 12,212,866; asm: 277,256; perl: 53,999; xml: 47,771; makefile: 30,481; sh: 8,035; python: 6,583; cpp: 5,121; yacc: 4,254; lex: 2,215; awk: 741; pascal: 231; lisp: 218; sed: 30
file content (30 lines) | stat: -rw-r--r-- 622 bytes parent folder | download | duplicates (43)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 *	crc16.h - CRC-16 routine
 *
 * Implements the standard CRC-16:
 *   Width 16
 *   Poly  0x8005 (x^16 + x^15 + x^2 + 1)
 *   Init  0
 *
 * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
 *
 * This source code is licensed under the GNU General Public License,
 * Version 2. See the file COPYING for more details.
 */

#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 */