Skip to content

Commit

Permalink
lib/crc32: make crc32c() go directly to lib
Browse files Browse the repository at this point in the history
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 <ardb@kernel.org>
Link: https://lore.kernel.org/r/20241202010844.144356-16-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
  • Loading branch information
Eric Biggers committed Dec 2, 2024
1 parent cc354fa commit 38a9a51
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 84 deletions.
7 changes: 5 additions & 2 deletions include/linux/crc32c.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
#ifndef _LINUX_CRC32C_H
#define _LINUX_CRC32C_H

#include <linux/types.h>
#include <linux/crc32.h>

extern u32 crc32c(u32 crc, const void *address, unsigned int length);
static inline u32 crc32c(u32 crc, const void *address, unsigned int length)
{
return __crc32c_le(crc, address, length);
}

/* This macro exists for backwards-compatibility. */
#define crc32c_le crc32c
Expand Down
10 changes: 3 additions & 7 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,10 @@ config CRC7

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

config CRC8
tristate "CRC8 function"
Expand Down
1 change: 0 additions & 1 deletion lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ obj-$(CONFIG_CRC64) += crc64.o
obj-$(CONFIG_CRC32_SELFTEST) += crc32test.o
obj-$(CONFIG_CRC4) += crc4.o
obj-$(CONFIG_CRC7) += crc7.o
obj-$(CONFIG_LIBCRC32C) += libcrc32c.o
obj-$(CONFIG_CRC8) += crc8.o
obj-$(CONFIG_CRC64_ROCKSOFT) += crc64-rocksoft.o
obj-$(CONFIG_XXHASH) += xxhash.o
Expand Down
74 changes: 0 additions & 74 deletions lib/libcrc32c.c

This file was deleted.

0 comments on commit 38a9a51

Please sign in to comment.