]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - lib/crc8.c
bbb229c3892c23f99df9b9873c922409410fa87a
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2013 Google, Inc
9 #include <asm/sections.h>
10 #include <u-boot/crc.h>
12 #define POLY (0x1070U << 3)
14 __rcode
static unsigned char _crc8(unsigned short data
)
18 for (i
= 0; i
< 8; i
++) {
24 return (unsigned char)(data
>> 8);
27 __rcode
unsigned int crc8(unsigned int crc
, const unsigned char *vptr
, int len
)
31 for (i
= 0; i
< len
; i
++)
32 crc
= _crc8((crc
^ vptr
[i
]) << 8);
37 void crc8_wd_buf(const unsigned char *input
, unsigned int len
,
38 unsigned char output
[1], unsigned int chunk_sz
)
40 *output
= crc8(0, input
, len
);