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

Configure Feed

Select the types of activity you want to include in your feed.

lib/crc32: standardize on crc32c() name for Castagnoli CRC32

For historical reasons, the Castagnoli CRC32 is available under 3 names:
crc32c(), crc32c_le(), and __crc32c_le(). Most callers use crc32c().
The more verbose versions are not really warranted; there is no "_be"
version that the "_le" version needs to be differentiated from, and the
leading underscores are pointless.

Therefore, let's standardize on just crc32c(). Remove the other two
names, and update callers accordingly.

Specifically, the new crc32c() comes from what was previously
__crc32c_le(), so compared to the old crc32c() it now takes a size_t
length rather than unsigned int, and it's now in linux/crc32.h instead
of just linux/crc32c.h (which includes linux/crc32.h).

Later patches will also rename __crc32c_le_combine(), crc32c_le_base(),
and crc32c_le_arch().

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250208024911.14936-5-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>

+32 -45
+2 -2
crypto/crc32c_generic.c
··· 94 94 { 95 95 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc); 96 96 97 - ctx->crc = __crc32c_le(ctx->crc, data, length); 97 + ctx->crc = crc32c(ctx->crc, data, length); 98 98 return 0; 99 99 } 100 100 ··· 115 115 static int __chksum_finup_arch(u32 *crcp, const u8 *data, unsigned int len, 116 116 u8 *out) 117 117 { 118 - put_unaligned_le32(~__crc32c_le(*crcp, data, len), out); 118 + put_unaligned_le32(~crc32c(*crcp, data, len), out); 119 119 return 0; 120 120 } 121 121
+1 -1
drivers/crypto/stm32/stm32-crc32.c
··· 162 162 if (mctx->poly == CRC32_POLY_LE) 163 163 ctx->partial = crc32_le(ctx->partial, d8, length); 164 164 else 165 - ctx->partial = __crc32c_le(ctx->partial, d8, length); 165 + ctx->partial = crc32c(ctx->partial, d8, length); 166 166 167 167 goto pm_out; 168 168 }
+15 -16
drivers/md/raid5-cache.c
··· 714 714 715 715 block = page_address(io->meta_page); 716 716 block->meta_size = cpu_to_le32(io->meta_offset); 717 - crc = crc32c_le(log->uuid_checksum, block, PAGE_SIZE); 717 + crc = crc32c(log->uuid_checksum, block, PAGE_SIZE); 718 718 block->checksum = cpu_to_le32(crc); 719 719 720 720 log->current_io = NULL; ··· 1020 1020 if (test_bit(STRIPE_LOG_TRAPPED, &sh->state)) 1021 1021 continue; 1022 1022 addr = kmap_local_page(sh->dev[i].page); 1023 - sh->dev[i].log_checksum = crc32c_le(log->uuid_checksum, 1024 - addr, PAGE_SIZE); 1023 + sh->dev[i].log_checksum = crc32c(log->uuid_checksum, 1024 + addr, PAGE_SIZE); 1025 1025 kunmap_local(addr); 1026 1026 } 1027 1027 parity_pages = 1 + !!(sh->qd_idx >= 0); ··· 1741 1741 le64_to_cpu(mb->position) != ctx->pos) 1742 1742 return -EINVAL; 1743 1743 1744 - crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE); 1744 + crc = crc32c(log->uuid_checksum, mb, PAGE_SIZE); 1745 1745 if (stored_crc != crc) 1746 1746 return -EINVAL; 1747 1747 ··· 1780 1780 return -ENOMEM; 1781 1781 r5l_recovery_create_empty_meta_block(log, page, pos, seq); 1782 1782 mb = page_address(page); 1783 - mb->checksum = cpu_to_le32(crc32c_le(log->uuid_checksum, 1784 - mb, PAGE_SIZE)); 1783 + mb->checksum = cpu_to_le32(crc32c(log->uuid_checksum, mb, PAGE_SIZE)); 1785 1784 if (!sync_page_io(log->rdev, pos, PAGE_SIZE, page, REQ_OP_WRITE | 1786 1785 REQ_SYNC | REQ_FUA, false)) { 1787 1786 __free_page(page); ··· 1975 1976 1976 1977 r5l_recovery_read_page(log, ctx, page, log_offset); 1977 1978 addr = kmap_local_page(page); 1978 - checksum = crc32c_le(log->uuid_checksum, addr, PAGE_SIZE); 1979 + checksum = crc32c(log->uuid_checksum, addr, PAGE_SIZE); 1979 1980 kunmap_local(addr); 1980 1981 return (le32_to_cpu(log_checksum) == checksum) ? 0 : -EINVAL; 1981 1982 } ··· 2378 2379 raid5_compute_blocknr(sh, i, 0)); 2379 2380 addr = kmap_local_page(dev->page); 2380 2381 payload->checksum[0] = cpu_to_le32( 2381 - crc32c_le(log->uuid_checksum, addr, 2382 - PAGE_SIZE)); 2382 + crc32c(log->uuid_checksum, addr, 2383 + PAGE_SIZE)); 2383 2384 kunmap_local(addr); 2384 2385 sync_page_io(log->rdev, write_pos, PAGE_SIZE, 2385 2386 dev->page, REQ_OP_WRITE, false); ··· 2391 2392 } 2392 2393 } 2393 2394 mb->meta_size = cpu_to_le32(offset); 2394 - mb->checksum = cpu_to_le32(crc32c_le(log->uuid_checksum, 2395 - mb, PAGE_SIZE)); 2395 + mb->checksum = cpu_to_le32(crc32c(log->uuid_checksum, 2396 + mb, PAGE_SIZE)); 2396 2397 sync_page_io(log->rdev, ctx->pos, PAGE_SIZE, page, 2397 2398 REQ_OP_WRITE | REQ_SYNC | REQ_FUA, false); 2398 2399 sh->log_start = ctx->pos; ··· 2884 2885 if (!test_bit(R5_Wantwrite, &sh->dev[i].flags)) 2885 2886 continue; 2886 2887 addr = kmap_local_page(sh->dev[i].page); 2887 - sh->dev[i].log_checksum = crc32c_le(log->uuid_checksum, 2888 - addr, PAGE_SIZE); 2888 + sh->dev[i].log_checksum = crc32c(log->uuid_checksum, 2889 + addr, PAGE_SIZE); 2889 2890 kunmap_local(addr); 2890 2891 pages++; 2891 2892 } ··· 2968 2969 } 2969 2970 stored_crc = le32_to_cpu(mb->checksum); 2970 2971 mb->checksum = 0; 2971 - expected_crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE); 2972 + expected_crc = crc32c(log->uuid_checksum, mb, PAGE_SIZE); 2972 2973 if (stored_crc != expected_crc) { 2973 2974 create_super = true; 2974 2975 goto create; ··· 3076 3077 return -ENOMEM; 3077 3078 log->rdev = rdev; 3078 3079 log->need_cache_flush = bdev_write_cache(rdev->bdev); 3079 - log->uuid_checksum = crc32c_le(~0, rdev->mddev->uuid, 3080 - sizeof(rdev->mddev->uuid)); 3080 + log->uuid_checksum = crc32c(~0, rdev->mddev->uuid, 3081 + sizeof(rdev->mddev->uuid)); 3081 3082 3082 3083 mutex_init(&log->io_mutex); 3083 3084
+8 -8
drivers/md/raid5-ppl.c
··· 346 346 if (!test_bit(STRIPE_FULL_WRITE, &sh->state)) { 347 347 le32_add_cpu(&e->pp_size, PAGE_SIZE); 348 348 io->pp_size += PAGE_SIZE; 349 - e->checksum = cpu_to_le32(crc32c_le(le32_to_cpu(e->checksum), 350 - page_address(sh->ppl_page), 351 - PAGE_SIZE)); 349 + e->checksum = cpu_to_le32(crc32c(le32_to_cpu(e->checksum), 350 + page_address(sh->ppl_page), 351 + PAGE_SIZE)); 352 352 } 353 353 354 354 list_add_tail(&sh->log_list, &io->stripe_list); ··· 454 454 } 455 455 456 456 pplhdr->entries_count = cpu_to_le32(io->entries_count); 457 - pplhdr->checksum = cpu_to_le32(~crc32c_le(~0, pplhdr, PPL_HEADER_SIZE)); 457 + pplhdr->checksum = cpu_to_le32(~crc32c(~0, pplhdr, PPL_HEADER_SIZE)); 458 458 459 459 /* Rewind the buffer if current PPL is larger then remaining space */ 460 460 if (log->use_multippl && ··· 998 998 goto out; 999 999 } 1000 1000 1001 - crc = crc32c_le(crc, page_address(page), s); 1001 + crc = crc32c(crc, page_address(page), s); 1002 1002 1003 1003 pp_size -= s; 1004 1004 sector += s >> 9; ··· 1052 1052 log->rdev->ppl.size, GFP_NOIO, 0); 1053 1053 memset(pplhdr->reserved, 0xff, PPL_HDR_RESERVED); 1054 1054 pplhdr->signature = cpu_to_le32(log->ppl_conf->signature); 1055 - pplhdr->checksum = cpu_to_le32(~crc32c_le(~0, pplhdr, PAGE_SIZE)); 1055 + pplhdr->checksum = cpu_to_le32(~crc32c(~0, pplhdr, PAGE_SIZE)); 1056 1056 1057 1057 if (!sync_page_io(rdev, rdev->ppl.sector - rdev->data_offset, 1058 1058 PPL_HEADER_SIZE, page, REQ_OP_WRITE | REQ_SYNC | ··· 1106 1106 /* check header validity */ 1107 1107 crc_stored = le32_to_cpu(pplhdr->checksum); 1108 1108 pplhdr->checksum = 0; 1109 - crc = ~crc32c_le(~0, pplhdr, PAGE_SIZE); 1109 + crc = ~crc32c(~0, pplhdr, PAGE_SIZE); 1110 1110 1111 1111 if (crc_stored != crc) { 1112 1112 pr_debug("%s: ppl header crc does not match: stored: 0x%x calculated: 0x%x (offset: %llu)\n", ··· 1390 1390 spin_lock_init(&ppl_conf->no_mem_stripes_lock); 1391 1391 1392 1392 if (!mddev->external) { 1393 - ppl_conf->signature = ~crc32c_le(~0, mddev->uuid, sizeof(mddev->uuid)); 1393 + ppl_conf->signature = ~crc32c(~0, mddev->uuid, sizeof(mddev->uuid)); 1394 1394 ppl_conf->block_size = 512; 1395 1395 } else { 1396 1396 ppl_conf->block_size =
+1 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
··· 2593 2593 /********************* Multicast verbs: SET, CLEAR ****************************/ 2594 2594 static inline u8 bnx2x_mcast_bin_from_mac(u8 *mac) 2595 2595 { 2596 - return (crc32c_le(0, mac, ETH_ALEN) >> 24) & 0xff; 2596 + return (crc32c(0, mac, ETH_ALEN) >> 24) & 0xff; 2597 2597 } 2598 2598 2599 2599 struct bnx2x_mcast_mac_elem {
+1 -1
drivers/thunderbolt/ctl.c
··· 312 312 313 313 static __be32 tb_crc(const void *data, size_t len) 314 314 { 315 - return cpu_to_be32(~__crc32c_le(~0, data, len)); 315 + return cpu_to_be32(~crc32c(~0, data, len)); 316 316 } 317 317 318 318 static void tb_ctl_pkg_free(struct ctl_pkg *pkg)
+1 -1
drivers/thunderbolt/eeprom.c
··· 211 211 212 212 static u32 tb_crc32(void *data, size_t len) 213 213 { 214 - return ~__crc32c_le(~0, data, len); 214 + return ~crc32c(~0, data, len); 215 215 } 216 216 217 217 #define TB_DROM_DATA_START 13
+2 -3
include/linux/crc32.h
··· 29 29 return crc32_be_base(crc, p, len); 30 30 } 31 31 32 - /* TODO: leading underscores should be dropped once callers have been updated */ 33 - static inline u32 __crc32c_le(u32 crc, const void *p, size_t len) 32 + static inline u32 crc32c(u32 crc, const void *p, size_t len) 34 33 { 35 34 if (IS_ENABLED(CONFIG_CRC32_ARCH)) 36 35 return crc32c_le_arch(crc, p, len); ··· 44 45 */ 45 46 #define CRC32_LE_OPTIMIZATION BIT(0) /* crc32_le() is optimized */ 46 47 #define CRC32_BE_OPTIMIZATION BIT(1) /* crc32_be() is optimized */ 47 - #define CRC32C_OPTIMIZATION BIT(2) /* __crc32c_le() is optimized */ 48 + #define CRC32C_OPTIMIZATION BIT(2) /* crc32c() is optimized */ 48 49 #if IS_ENABLED(CONFIG_CRC32_ARCH) 49 50 u32 crc32_optimizations(void); 50 51 #else
-8
include/linux/crc32c.h
··· 4 4 5 5 #include <linux/crc32.h> 6 6 7 - static inline u32 crc32c(u32 crc, const void *address, unsigned int length) 8 - { 9 - return __crc32c_le(crc, address, length); 10 - } 11 - 12 - /* This macro exists for backwards-compatibility. */ 13 - #define crc32c_le crc32c 14 - 15 7 #endif /* _LINUX_CRC32C_H */
-3
include/net/sctp/checksum.h
··· 30 30 31 31 static inline __wsum sctp_csum_update(const void *buff, int len, __wsum sum) 32 32 { 33 - /* This uses the crypto implementation of crc32c, which is either 34 - * implemented w/ hardware support or resolves to __crc32c_le(). 35 - */ 36 33 return (__force __wsum)crc32c((__force __u32)sum, buff, len); 37 34 } 38 35
+1 -1
sound/soc/codecs/aw88395/aw88395_device.c
··· 424 424 return -EINVAL; 425 425 } 426 426 427 - crc_value = __crc32c_le(0xFFFFFFFF, crc_dsp_cfg->data, crc_data_len) ^ 0xFFFFFFFF; 427 + crc_value = crc32c(0xFFFFFFFF, crc_dsp_cfg->data, crc_data_len) ^ 0xFFFFFFFF; 428 428 429 429 return aw_dev_dsp_write(aw_dev, AW88395_DSP_REG_CRC_ADDR, crc_value, 430 430 AW88395_DSP_32_DATA);