1 /* SPDX-License-Identifier: GPL-2.0-only */
5 uint8_t crc7_byte(uint8_t prev_crc
, uint8_t data
)
7 const uint8_t g
= 0x89;
9 for (int i
= 0; i
< 8; i
++) {
17 uint16_t crc16_byte(uint16_t prev_crc
, uint8_t data
)
19 prev_crc
= (uint8_t)(prev_crc
>> 8)|(prev_crc
<< 8);
21 prev_crc
^= (uint8_t)(prev_crc
& 0xff) >> 4;
22 prev_crc
^= (prev_crc
<< 8) << 4;
23 prev_crc
^= ((prev_crc
& 0xff) << 4) << 1;
27 uint32_t crc32_byte(uint32_t prev_crc
, uint8_t data
)
29 prev_crc
^= (uint32_t)data
<< 24;
31 for (int i
= 0; i
< 8; i
++) {
32 if ((prev_crc
& 0x80000000UL
) != 0)
33 prev_crc
= ((prev_crc
<< 1) ^ 0x04C11DB7UL
);