Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+164 -166
+7 -7
Documentation/core-api/kernel-api.rst
··· 136 136 CRC Functions 137 137 ------------- 138 138 139 - .. kernel-doc:: lib/crc4.c 139 + .. kernel-doc:: lib/crc/crc4.c 140 140 :export: 141 141 142 - .. kernel-doc:: lib/crc7.c 142 + .. kernel-doc:: lib/crc/crc7.c 143 143 :export: 144 144 145 - .. kernel-doc:: lib/crc8.c 145 + .. kernel-doc:: lib/crc/crc8.c 146 146 :export: 147 147 148 - .. kernel-doc:: lib/crc16.c 148 + .. kernel-doc:: lib/crc/crc16.c 149 149 :export: 150 150 151 - .. kernel-doc:: lib/crc32.c 151 + .. kernel-doc:: lib/crc/crc32.c 152 152 153 - .. kernel-doc:: lib/crc-ccitt.c 153 + .. kernel-doc:: lib/crc/crc-ccitt.c 154 154 :export: 155 155 156 - .. kernel-doc:: lib/crc-itu-t.c 156 + .. kernel-doc:: lib/crc/crc-itu-t.c 157 157 :export: 158 158 159 159 Base 2 log and power Functions
+1 -2
MAINTAINERS
··· 6361 6361 F: Documentation/staging/crc* 6362 6362 F: arch/*/lib/crc* 6363 6363 F: include/linux/crc* 6364 - F: lib/crc* 6365 - F: lib/tests/crc_kunit.c 6364 + F: lib/crc/ 6366 6365 F: scripts/gen-crc-consts.py 6367 6366 6368 6367 CREATIVE SB0540
-3
include/linux/crc64.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * See lib/crc64.c for the related specification and polynomial arithmetic. 4 - */ 5 2 #ifndef _LINUX_CRC64_H 6 3 #define _LINUX_CRC64_H 7 4
+1 -87
lib/Kconfig
··· 136 136 Create tracepoints for MMIO read/write operations. These trace events 137 137 can be used for logging all MMIO read/write operations. 138 138 139 + source "lib/crc/Kconfig" 139 140 source "lib/crypto/Kconfig" 140 - 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 141 228 142 config XXHASH 229 143 tristate
-21
lib/Kconfig.debug
··· 2901 2901 2902 2902 If unsure, say N. 2903 2903 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 - 2925 2904 config SIPHASH_KUNIT_TEST 2926 2905 tristate "Perform selftest on siphash functions" if !KUNIT_ALL_TESTS 2927 2906 depends on KUNIT
+1 -31
lib/Makefile
··· 122 122 obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o 123 123 CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any) 124 124 125 - obj-y += math/ crypto/ tests/ vdso/ 125 + obj-y += math/ crc/ crypto/ tests/ vdso/ 126 126 127 127 obj-$(CONFIG_GENERIC_IOMAP) += iomap.o 128 128 obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o ··· 148 148 obj-$(CONFIG_LINEAR_RANGES) += linear_ranges.o 149 149 obj-$(CONFIG_PACKING) += packing.o 150 150 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 160 151 obj-$(CONFIG_XXHASH) += xxhash.o 161 152 obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o 162 153 ··· 284 293 obj-$(CONFIG_ASN1_ENCODER) += asn1_encoder.o 285 294 286 295 obj-$(CONFIG_FONT_SUPPORT) += fonts/ 287 - 288 - hostprogs := gen_crc32table 289 - hostprogs += gen_crc64table 290 - clean-files := crc32table.h 291 - clean-files += crc64table.h 292 - 293 - $(obj)/crc32.o: $(obj)/crc32table.h 294 - 295 - quiet_cmd_crc32 = GEN $@ 296 - cmd_crc32 = $< > $@ 297 - 298 - $(obj)/crc32table.h: $(obj)/gen_crc32table 299 - $(call cmd,crc32) 300 - 301 - $(obj)/crc64.o: $(obj)/crc64table.h 302 - 303 - quiet_cmd_crc64 = GEN $@ 304 - cmd_crc64 = $< > $@ 305 - 306 - $(obj)/crc64table.h: $(obj)/gen_crc64table 307 - $(call cmd,crc64) 308 296 309 297 # 310 298 # Build a fast OID lookip registry from include/linux/oid_registry.h
-3
lib/crc-ccitt.c lib/crc/crc-ccitt.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * linux/lib/crc-ccitt.c 4 - */ 5 2 6 3 #include <linux/types.h> 7 4 #include <linux/module.h>
lib/crc-itu-t.c lib/crc/crc-itu-t.c
lib/crc-t10dif.c lib/crc/crc-t10dif.c
+5
lib/crc/.gitignore
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + /crc32table.h 3 + /crc64table.h 4 + /gen_crc32table 5 + /gen_crc64table
+111
lib/crc/Kconfig
··· 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.
+32
lib/crc/Makefile
··· 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)
+2
lib/crc/tests/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + obj-$(CONFIG_CRC_KUNIT_TEST) += crc_kunit.o
lib/crc16.c lib/crc/crc16.c
lib/crc32.c lib/crc/crc32.c
lib/crc4.c lib/crc/crc4.c
lib/crc64.c lib/crc/crc64.c
lib/crc7.c lib/crc/crc7.c
lib/crc8.c lib/crc/crc8.c
+2 -2
lib/gen_crc32table.c lib/crc/gen_crc32table.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <stdio.h> 3 - #include "../include/linux/crc32poly.h" 4 - #include "../include/generated/autoconf.h" 3 + #include "../../include/linux/crc32poly.h" 4 + #include "../../include/generated/autoconf.h" 5 5 #include <inttypes.h> 6 6 7 7 static uint32_t crc32table_le[256];
+2 -9
lib/gen_crc64table.c lib/crc/gen_crc64table.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * Generate lookup table for the table-driven CRC64 calculation. 4 - * 5 - * gen_crc64table is executed in kernel build time and generates 6 - * lib/crc64table.h. This header is included by lib/crc64.c for 7 - * the table-driven CRC64 calculation. 8 - * 9 - * See lib/crc64.c for more information about which specification 10 - * and polynomial arithmetic that gen_crc64table.c follows to 11 - * generate the lookup table. 3 + * This host program runs at kernel build time and generates the lookup tables 4 + * used by the generic CRC64 code. 12 5 * 13 6 * Copyright 2018 SUSE Linux. 14 7 * Author: Coly Li <colyli@suse.de>
-1
lib/tests/Makefile
··· 10 10 obj-$(CONFIG_CHECKSUM_KUNIT) += checksum_kunit.o 11 11 obj-$(CONFIG_CMDLINE_KUNIT_TEST) += cmdline_kunit.o 12 12 obj-$(CONFIG_CPUMASK_KUNIT_TEST) += cpumask_kunit.o 13 - obj-$(CONFIG_CRC_KUNIT_TEST) += crc_kunit.o 14 13 CFLAGS_fortify_kunit.o += $(call cc-disable-warning, unsequenced) 15 14 CFLAGS_fortify_kunit.o += $(call cc-disable-warning, stringop-overread) 16 15 CFLAGS_fortify_kunit.o += $(call cc-disable-warning, stringop-truncation)
lib/tests/crc_kunit.c lib/crc/tests/crc_kunit.c