Skip to content

Commit 3937f6d

Browse files
committed
lib/crc16: unexport crc16_table and crc16_byte()
Now that neither crc16_table nor crc16_byte() is used outside lib/crc16.c, fold them into lib/crc16.c. Acked-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent 0769ebe commit 3937f6d

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

include/linux/crc16.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@
1515

1616
#include <linux/types.h>
1717

18-
extern u16 const crc16_table[256];
19-
20-
extern u16 crc16(u16 crc, const u8 *buffer, size_t len);
21-
22-
static inline u16 crc16_byte(u16 crc, const u8 data)
23-
{
24-
return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
25-
}
18+
u16 crc16(u16 crc, const u8 *p, size_t len);
2619

2720
#endif /* __CRC16_H */
2821

lib/crc16.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/crc16.h>
99

1010
/** 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] = {
1212
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
1313
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
1414
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
@@ -42,20 +42,19 @@ u16 const crc16_table[256] = {
4242
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
4343
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
4444
};
45-
EXPORT_SYMBOL(crc16_table);
4645

4746
/**
4847
* crc16 - compute the CRC-16 for the data buffer
4948
* @crc: previous CRC value
50-
* @buffer: data pointer
49+
* @p: data pointer
5150
* @len: number of bytes in the buffer
5251
*
5352
* Returns the updated CRC value.
5453
*/
55-
u16 crc16(u16 crc, u8 const *buffer, size_t len)
54+
u16 crc16(u16 crc, const u8 *p, size_t len)
5655
{
5756
while (len--)
58-
crc = crc16_byte(crc, *buffer++);
57+
crc = (crc >> 8) ^ crc16_table[(crc & 0xff) ^ *p++];
5958
return crc;
6059
}
6160
EXPORT_SYMBOL(crc16);

0 commit comments

Comments
 (0)