Skip to content

Commit 38a9a51

Browse files
committed
lib/crc32: make crc32c() go directly to lib
Now that the lower level __crc32c_le() library function is optimized for each architecture, make crc32c() just call that instead of taking an inefficient and error-prone detour through the shash API. Note: a future cleanup should make crc32c_le() be the actual library function instead of __crc32c_le(). That will require updating callers of __crc32c_le() to use crc32c_le() instead, and updating callers of crc32c_le() that expect a 'const void *' arg to expect 'const u8 *' instead. Similarly, a future cleanup should remove LIBCRC32C by making everyone who is selecting it just select CRC32 directly instead. Reviewed-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent cc354fa commit 38a9a51

File tree

4 files changed

+8
-84
lines changed

4 files changed

+8
-84
lines changed

include/linux/crc32c.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
#ifndef _LINUX_CRC32C_H
33
#define _LINUX_CRC32C_H
44

5-
#include <linux/types.h>
5+
#include <linux/crc32.h>
66

7-
extern u32 crc32c(u32 crc, const void *address, unsigned int length);
7+
static inline u32 crc32c(u32 crc, const void *address, unsigned int length)
8+
{
9+
return __crc32c_le(crc, address, length);
10+
}
811

912
/* This macro exists for backwards-compatibility. */
1013
#define crc32c_le crc32c

lib/Kconfig

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,10 @@ config CRC7
310310

311311
config LIBCRC32C
312312
tristate "CRC32c (Castagnoli, et al) Cyclic Redundancy-Check"
313-
select CRYPTO
314-
select CRYPTO_CRC32C
313+
select CRC32
315314
help
316-
This option is provided for the case where no in-kernel-tree
317-
modules require CRC32c functions, but a module built outside the
318-
kernel tree does. Such modules that use library CRC32c functions
319-
require M here. See Castagnoli93.
320-
Module will be libcrc32c.
315+
This option just selects CRC32 and is provided for compatibility
316+
purposes until the users are updated to select CRC32 directly.
321317

322318
config CRC8
323319
tristate "CRC8 function"

lib/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ obj-$(CONFIG_CRC64) += crc64.o
167167
obj-$(CONFIG_CRC32_SELFTEST) += crc32test.o
168168
obj-$(CONFIG_CRC4) += crc4.o
169169
obj-$(CONFIG_CRC7) += crc7.o
170-
obj-$(CONFIG_LIBCRC32C) += libcrc32c.o
171170
obj-$(CONFIG_CRC8) += crc8.o
172171
obj-$(CONFIG_CRC64_ROCKSOFT) += crc64-rocksoft.o
173172
obj-$(CONFIG_XXHASH) += xxhash.o

lib/libcrc32c.c

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)