Skip to content

Commit 89a5159

Browse files
author
Eric Biggers
committed
lib/crc: Move files into lib/crc/
Move all CRC files in lib/ into a subdirectory lib/crc/ to keep them from cluttering up the main lib/ directory. Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com> Acked-by: Ingo Molnar <mingo@kernel.org> Acked-by: "Jason A. Donenfeld" <Jason@zx2c4.com> Link: https://lore.kernel.org/r/20250607200454.73587-2-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
1 parent f2703a1 commit 89a5159

23 files changed

Lines changed: 164 additions & 166 deletions

Documentation/core-api/kernel-api.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,24 @@ Arithmetic Overflow Checking
136136
CRC Functions
137137
-------------
138138

139-
.. kernel-doc:: lib/crc4.c
139+
.. kernel-doc:: lib/crc/crc4.c
140140
:export:
141141

142-
.. kernel-doc:: lib/crc7.c
142+
.. kernel-doc:: lib/crc/crc7.c
143143
:export:
144144

145-
.. kernel-doc:: lib/crc8.c
145+
.. kernel-doc:: lib/crc/crc8.c
146146
:export:
147147

148-
.. kernel-doc:: lib/crc16.c
148+
.. kernel-doc:: lib/crc/crc16.c
149149
:export:
150150

151-
.. kernel-doc:: lib/crc32.c
151+
.. kernel-doc:: lib/crc/crc32.c
152152

153-
.. kernel-doc:: lib/crc-ccitt.c
153+
.. kernel-doc:: lib/crc/crc-ccitt.c
154154
:export:
155155

156-
.. kernel-doc:: lib/crc-itu-t.c
156+
.. kernel-doc:: lib/crc/crc-itu-t.c
157157
:export:
158158

159159
Base 2 log and power Functions

MAINTAINERS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6361,8 +6361,7 @@ T: git https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git crc-ne
63616361
F: Documentation/staging/crc*
63626362
F: arch/*/lib/crc*
63636363
F: include/linux/crc*
6364-
F: lib/crc*
6365-
F: lib/tests/crc_kunit.c
6364+
F: lib/crc/
63666365
F: scripts/gen-crc-consts.py
63676366

63686367
CREATIVE SB0540

include/linux/crc64.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2-
/*
3-
* See lib/crc64.c for the related specification and polynomial arithmetic.
4-
*/
52
#ifndef _LINUX_CRC64_H
63
#define _LINUX_CRC64_H
74

lib/Kconfig

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -136,95 +136,9 @@ config TRACE_MMIO_ACCESS
136136
Create tracepoints for MMIO read/write operations. These trace events
137137
can be used for logging all MMIO read/write operations.
138138

139+
source "lib/crc/Kconfig"
139140
source "lib/crypto/Kconfig"
140141

141-
config CRC_CCITT
142-
tristate
143-
help
144-
The CRC-CCITT library functions. Select this if your module uses any
145-
of the functions from <linux/crc-ccitt.h>.
146-
147-
config CRC16
148-
tristate
149-
help
150-
The CRC16 library functions. Select this if your module uses any of
151-
the functions from <linux/crc16.h>.
152-
153-
config CRC_T10DIF
154-
tristate
155-
help
156-
The CRC-T10DIF library functions. Select this if your module uses
157-
any of the functions from <linux/crc-t10dif.h>.
158-
159-
config ARCH_HAS_CRC_T10DIF
160-
bool
161-
162-
config CRC_T10DIF_ARCH
163-
tristate
164-
default CRC_T10DIF if ARCH_HAS_CRC_T10DIF && CRC_OPTIMIZATIONS
165-
166-
config CRC_ITU_T
167-
tristate
168-
help
169-
The CRC-ITU-T library functions. Select this if your module uses
170-
any of the functions from <linux/crc-itu-t.h>.
171-
172-
config CRC32
173-
tristate
174-
select BITREVERSE
175-
help
176-
The CRC32 library functions. Select this if your module uses any of
177-
the functions from <linux/crc32.h> or <linux/crc32c.h>.
178-
179-
config ARCH_HAS_CRC32
180-
bool
181-
182-
config CRC32_ARCH
183-
tristate
184-
default CRC32 if ARCH_HAS_CRC32 && CRC_OPTIMIZATIONS
185-
186-
config CRC64
187-
tristate
188-
help
189-
The CRC64 library functions. Select this if your module uses any of
190-
the functions from <linux/crc64.h>.
191-
192-
config ARCH_HAS_CRC64
193-
bool
194-
195-
config CRC64_ARCH
196-
tristate
197-
default CRC64 if ARCH_HAS_CRC64 && CRC_OPTIMIZATIONS
198-
199-
config CRC4
200-
tristate
201-
help
202-
The CRC4 library functions. Select this if your module uses any of
203-
the functions from <linux/crc4.h>.
204-
205-
config CRC7
206-
tristate
207-
help
208-
The CRC7 library functions. Select this if your module uses any of
209-
the functions from <linux/crc7.h>.
210-
211-
config CRC8
212-
tristate
213-
help
214-
The CRC8 library functions. Select this if your module uses any of
215-
the functions from <linux/crc8.h>.
216-
217-
config CRC_OPTIMIZATIONS
218-
bool "Enable optimized CRC implementations" if EXPERT
219-
default y
220-
help
221-
Disabling this option reduces code size slightly by disabling the
222-
architecture-optimized implementations of any CRC variants that are
223-
enabled. CRC checksumming performance may get much slower.
224-
225-
Keep this enabled unless you're really trying to minimize the size of
226-
the kernel.
227-
228142
config XXHASH
229143
tristate
230144

lib/Kconfig.debug

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,27 +2901,6 @@ config HW_BREAKPOINT_KUNIT_TEST
29012901

29022902
If unsure, say N.
29032903

2904-
config CRC_KUNIT_TEST
2905-
tristate "KUnit tests for CRC functions" if !KUNIT_ALL_TESTS
2906-
depends on KUNIT
2907-
default KUNIT_ALL_TESTS
2908-
select CRC7
2909-
select CRC16
2910-
select CRC_T10DIF
2911-
select CRC32
2912-
select CRC64
2913-
help
2914-
Unit tests for the CRC library functions.
2915-
2916-
This is intended to help people writing architecture-specific
2917-
optimized versions. If unsure, say N.
2918-
2919-
config CRC_BENCHMARK
2920-
bool "Benchmark for the CRC functions"
2921-
depends on CRC_KUNIT_TEST
2922-
help
2923-
Include benchmarks in the KUnit test suite for the CRC functions.
2924-
29252904
config SIPHASH_KUNIT_TEST
29262905
tristate "Perform selftest on siphash functions" if !KUNIT_ALL_TESTS
29272906
depends on KUNIT

lib/Makefile

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ endif
122122
obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o
123123
CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any)
124124

125-
obj-y += math/ crypto/ tests/ vdso/
125+
obj-y += math/ crc/ crypto/ tests/ vdso/
126126

127127
obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
128128
obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
@@ -148,15 +148,6 @@ obj-$(CONFIG_BITREVERSE) += bitrev.o
148148
obj-$(CONFIG_LINEAR_RANGES) += linear_ranges.o
149149
obj-$(CONFIG_PACKING) += packing.o
150150
obj-$(CONFIG_PACKING_KUNIT_TEST) += packing_test.o
151-
obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o
152-
obj-$(CONFIG_CRC16) += crc16.o
153-
obj-$(CONFIG_CRC_T10DIF)+= crc-t10dif.o
154-
obj-$(CONFIG_CRC_ITU_T) += crc-itu-t.o
155-
obj-$(CONFIG_CRC32) += crc32.o
156-
obj-$(CONFIG_CRC64) += crc64.o
157-
obj-$(CONFIG_CRC4) += crc4.o
158-
obj-$(CONFIG_CRC7) += crc7.o
159-
obj-$(CONFIG_CRC8) += crc8.o
160151
obj-$(CONFIG_XXHASH) += xxhash.o
161152
obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o
162153

@@ -294,27 +285,6 @@ obj-$(CONFIG_ASN1_ENCODER) += asn1_encoder.o
294285

295286
obj-$(CONFIG_FONT_SUPPORT) += fonts/
296287

297-
hostprogs := gen_crc32table
298-
hostprogs += gen_crc64table
299-
clean-files := crc32table.h
300-
clean-files += crc64table.h
301-
302-
$(obj)/crc32.o: $(obj)/crc32table.h
303-
304-
quiet_cmd_crc32 = GEN $@
305-
cmd_crc32 = $< > $@
306-
307-
$(obj)/crc32table.h: $(obj)/gen_crc32table
308-
$(call cmd,crc32)
309-
310-
$(obj)/crc64.o: $(obj)/crc64table.h
311-
312-
quiet_cmd_crc64 = GEN $@
313-
cmd_crc64 = $< > $@
314-
315-
$(obj)/crc64table.h: $(obj)/gen_crc64table
316-
$(call cmd,crc64)
317-
318288
#
319289
# Build a fast OID lookip registry from include/linux/oid_registry.h
320290
#

lib/crc/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
/crc32table.h
3+
/crc64table.h
4+
/gen_crc32table
5+
/gen_crc64table

lib/crc/Kconfig

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
# Kconfig for the kernel's cyclic redundancy check (CRC) library code
4+
5+
config CRC4
6+
tristate
7+
help
8+
The CRC4 library functions. Select this if your module uses any of
9+
the functions from <linux/crc4.h>.
10+
11+
config CRC7
12+
tristate
13+
help
14+
The CRC7 library functions. Select this if your module uses any of
15+
the functions from <linux/crc7.h>.
16+
17+
config CRC8
18+
tristate
19+
help
20+
The CRC8 library functions. Select this if your module uses any of
21+
the functions from <linux/crc8.h>.
22+
23+
config CRC16
24+
tristate
25+
help
26+
The CRC16 library functions. Select this if your module uses any of
27+
the functions from <linux/crc16.h>.
28+
29+
config CRC_CCITT
30+
tristate
31+
help
32+
The CRC-CCITT library functions. Select this if your module uses any
33+
of the functions from <linux/crc-ccitt.h>.
34+
35+
config CRC_ITU_T
36+
tristate
37+
help
38+
The CRC-ITU-T library functions. Select this if your module uses
39+
any of the functions from <linux/crc-itu-t.h>.
40+
41+
config CRC_T10DIF
42+
tristate
43+
help
44+
The CRC-T10DIF library functions. Select this if your module uses
45+
any of the functions from <linux/crc-t10dif.h>.
46+
47+
config ARCH_HAS_CRC_T10DIF
48+
bool
49+
50+
config CRC_T10DIF_ARCH
51+
tristate
52+
default CRC_T10DIF if ARCH_HAS_CRC_T10DIF && CRC_OPTIMIZATIONS
53+
54+
config CRC32
55+
tristate
56+
select BITREVERSE
57+
help
58+
The CRC32 library functions. Select this if your module uses any of
59+
the functions from <linux/crc32.h> or <linux/crc32c.h>.
60+
61+
config ARCH_HAS_CRC32
62+
bool
63+
64+
config CRC32_ARCH
65+
tristate
66+
default CRC32 if ARCH_HAS_CRC32 && CRC_OPTIMIZATIONS
67+
68+
config CRC64
69+
tristate
70+
help
71+
The CRC64 library functions. Select this if your module uses any of
72+
the functions from <linux/crc64.h>.
73+
74+
config ARCH_HAS_CRC64
75+
bool
76+
77+
config CRC64_ARCH
78+
tristate
79+
default CRC64 if ARCH_HAS_CRC64 && CRC_OPTIMIZATIONS
80+
81+
config CRC_OPTIMIZATIONS
82+
bool "Enable optimized CRC implementations" if EXPERT
83+
default y
84+
help
85+
Disabling this option reduces code size slightly by disabling the
86+
architecture-optimized implementations of any CRC variants that are
87+
enabled. CRC checksumming performance may get much slower.
88+
89+
Keep this enabled unless you're really trying to minimize the size of
90+
the kernel.
91+
92+
config CRC_KUNIT_TEST
93+
tristate "KUnit tests for CRC functions" if !KUNIT_ALL_TESTS
94+
depends on KUNIT
95+
default KUNIT_ALL_TESTS
96+
select CRC7
97+
select CRC16
98+
select CRC_T10DIF
99+
select CRC32
100+
select CRC64
101+
help
102+
Unit tests for the CRC library functions.
103+
104+
This is intended to help people writing architecture-specific
105+
optimized versions. If unsure, say N.
106+
107+
config CRC_BENCHMARK
108+
bool "Benchmark for the CRC functions"
109+
depends on CRC_KUNIT_TEST
110+
help
111+
Include benchmarks in the KUnit test suite for the CRC functions.

lib/crc/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
# Makefile for the kernel's cyclic redundancy check (CRC) library code
4+
5+
obj-$(CONFIG_CRC4) += crc4.o
6+
obj-$(CONFIG_CRC7) += crc7.o
7+
obj-$(CONFIG_CRC8) += crc8.o
8+
obj-$(CONFIG_CRC16) += crc16.o
9+
obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o
10+
obj-$(CONFIG_CRC_ITU_T) += crc-itu-t.o
11+
obj-$(CONFIG_CRC_T10DIF) += crc-t10dif.o
12+
obj-$(CONFIG_CRC32) += crc32.o
13+
obj-$(CONFIG_CRC64) += crc64.o
14+
obj-y += tests/
15+
16+
hostprogs := gen_crc32table gen_crc64table
17+
clean-files := crc32table.h crc64table.h
18+
19+
$(obj)/crc32.o: $(obj)/crc32table.h
20+
$(obj)/crc64.o: $(obj)/crc64table.h
21+
22+
quiet_cmd_crc32 = GEN $@
23+
cmd_crc32 = $< > $@
24+
25+
quiet_cmd_crc64 = GEN $@
26+
cmd_crc64 = $< > $@
27+
28+
$(obj)/crc32table.h: $(obj)/gen_crc32table
29+
$(call cmd,crc32)
30+
31+
$(obj)/crc64table.h: $(obj)/gen_crc64table
32+
$(call cmd,crc64)

lib/crc-ccitt.c renamed to lib/crc/crc-ccitt.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
// SPDX-License-Identifier: GPL-2.0-only
2-
/*
3-
* linux/lib/crc-ccitt.c
4-
*/
52

63
#include <linux/types.h>
74
#include <linux/module.h>

0 commit comments

Comments
 (0)