|
8 | 8 | #include <linux/crc16.h>
|
9 | 9 |
|
10 | 10 | /** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
|
11 |
| -u16 const crc16_table[256] = { |
| 11 | +static const u16 crc16_table[256] = { |
12 | 12 | 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
13 | 13 | 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
14 | 14 | 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
|
@@ -42,20 +42,19 @@ u16 const crc16_table[256] = {
|
42 | 42 | 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
43 | 43 | 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
44 | 44 | };
|
45 |
| -EXPORT_SYMBOL(crc16_table); |
46 | 45 |
|
47 | 46 | /**
|
48 | 47 | * crc16 - compute the CRC-16 for the data buffer
|
49 | 48 | * @crc: previous CRC value
|
50 |
| - * @buffer: data pointer |
| 49 | + * @p: data pointer |
51 | 50 | * @len: number of bytes in the buffer
|
52 | 51 | *
|
53 | 52 | * Returns the updated CRC value.
|
54 | 53 | */
|
55 |
| -u16 crc16(u16 crc, u8 const *buffer, size_t len) |
| 54 | +u16 crc16(u16 crc, const u8 *p, size_t len) |
56 | 55 | {
|
57 | 56 | while (len--)
|
58 |
| - crc = crc16_byte(crc, *buffer++); |
| 57 | + crc = (crc >> 8) ^ crc16_table[(crc & 0xff) ^ *p++]; |
59 | 58 | return crc;
|
60 | 59 | }
|
61 | 60 | EXPORT_SYMBOL(crc16);
|
|
0 commit comments