xref: /OK3568_Linux_fs/u-boot/include/linux/crc8.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (c) 2013 Google, Inc
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0+
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #ifndef __linux_crc8_h
9*4882a593Smuzhiyun #define __linux_crc8_h
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun /**
12*4882a593Smuzhiyun  * crc8() - Calculate and return CRC-8 of the data
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  * This uses an x^8 + x^2 + x + 1 polynomial.  A table-based algorithm would
15*4882a593Smuzhiyun  * be faster, but for only a few bytes it isn't worth the code size
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * @crc_start: CRC8 start value
18*4882a593Smuzhiyun  * @vptr: Buffer to checksum
19*4882a593Smuzhiyun  * @len: Length of buffer in bytes
20*4882a593Smuzhiyun  * @return CRC8 checksum
21*4882a593Smuzhiyun  */
22*4882a593Smuzhiyun unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len);
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #endif
25