Source
8
8
#include <linux/crc4.h>
9
9
#include <linux/module.h>
10
10
11
11
static const uint8_t crc4_tab[] = {
12
12
0x0, 0x7, 0xe, 0x9, 0xb, 0xc, 0x5, 0x2,
13
13
0x1, 0x6, 0xf, 0x8, 0xa, 0xd, 0x4, 0x3,
14
14
};
15
15
16
16
/**
17
17
* crc4 - calculate the 4-bit crc of a value.
18
-
* @crc: starting crc4
18
+
* @c: starting crc4
19
19
* @x: value to checksum
20
20
* @bits: number of bits in @x to checksum
21
21
*
22
22
* Returns the crc4 value of @x, using polynomial 0b10111.
23
23
*
24
24
* The @x value is treated as left-aligned, and bits above @bits are ignored
25
25
* in the crc calculations.
26
26
*/
27
27
uint8_t crc4(uint8_t c, uint64_t x, int bits)
28
28
{