Commit 8df36829 authored by Eric Biggers's avatar Eric Biggers
Browse files

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: default avatarArd Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250208024911.14936-5-ebiggers@kernel.org


Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent bc2736fe
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ static int chksum_update_arch(struct shash_desc *desc, const u8 *data,
{
	struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);

	ctx->crc = __crc32c_le(ctx->crc, data, length);
	ctx->crc = crc32c(ctx->crc, data, length);
	return 0;
}

@@ -115,7 +115,7 @@ static int __chksum_finup(u32 *crcp, const u8 *data, unsigned int len, u8 *out)
static int __chksum_finup_arch(u32 *crcp, const u8 *data, unsigned int len,
			       u8 *out)
{
	put_unaligned_le32(~__crc32c_le(*crcp, data, len), out);
	put_unaligned_le32(~crc32c(*crcp, data, len), out);
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ static int burst_update(struct shash_desc *desc, const u8 *d8,
		if (mctx->poly == CRC32_POLY_LE)
			ctx->partial = crc32_le(ctx->partial, d8, length);
		else
			ctx->partial = __crc32c_le(ctx->partial, d8, length);
			ctx->partial = crc32c(ctx->partial, d8, length);

		goto pm_out;
	}
+15 −16
Original line number Diff line number Diff line
@@ -714,7 +714,7 @@ static void r5l_submit_current_io(struct r5l_log *log)

	block = page_address(io->meta_page);
	block->meta_size = cpu_to_le32(io->meta_offset);
	crc = crc32c_le(log->uuid_checksum, block, PAGE_SIZE);
	crc = crc32c(log->uuid_checksum, block, PAGE_SIZE);
	block->checksum = cpu_to_le32(crc);

	log->current_io = NULL;
@@ -1020,7 +1020,7 @@ int r5l_write_stripe(struct r5l_log *log, struct stripe_head *sh)
		if (test_bit(STRIPE_LOG_TRAPPED, &sh->state))
			continue;
		addr = kmap_local_page(sh->dev[i].page);
		sh->dev[i].log_checksum = crc32c_le(log->uuid_checksum,
		sh->dev[i].log_checksum = crc32c(log->uuid_checksum,
						 addr, PAGE_SIZE);
		kunmap_local(addr);
	}
@@ -1741,7 +1741,7 @@ static int r5l_recovery_read_meta_block(struct r5l_log *log,
	    le64_to_cpu(mb->position) != ctx->pos)
		return -EINVAL;

	crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE);
	crc = crc32c(log->uuid_checksum, mb, PAGE_SIZE);
	if (stored_crc != crc)
		return -EINVAL;

@@ -1780,8 +1780,7 @@ static int r5l_log_write_empty_meta_block(struct r5l_log *log, sector_t pos,
		return -ENOMEM;
	r5l_recovery_create_empty_meta_block(log, page, pos, seq);
	mb = page_address(page);
	mb->checksum = cpu_to_le32(crc32c_le(log->uuid_checksum,
					     mb, PAGE_SIZE));
	mb->checksum = cpu_to_le32(crc32c(log->uuid_checksum, mb, PAGE_SIZE));
	if (!sync_page_io(log->rdev, pos, PAGE_SIZE, page, REQ_OP_WRITE |
			  REQ_SYNC | REQ_FUA, false)) {
		__free_page(page);
@@ -1976,7 +1975,7 @@ r5l_recovery_verify_data_checksum(struct r5l_log *log,

	r5l_recovery_read_page(log, ctx, page, log_offset);
	addr = kmap_local_page(page);
	checksum = crc32c_le(log->uuid_checksum, addr, PAGE_SIZE);
	checksum = crc32c(log->uuid_checksum, addr, PAGE_SIZE);
	kunmap_local(addr);
	return (le32_to_cpu(log_checksum) == checksum) ? 0 : -EINVAL;
}
@@ -2379,7 +2378,7 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
					raid5_compute_blocknr(sh, i, 0));
				addr = kmap_local_page(dev->page);
				payload->checksum[0] = cpu_to_le32(
					crc32c_le(log->uuid_checksum, addr,
					crc32c(log->uuid_checksum, addr,
					       PAGE_SIZE));
				kunmap_local(addr);
				sync_page_io(log->rdev, write_pos, PAGE_SIZE,
@@ -2392,7 +2391,7 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
			}
		}
		mb->meta_size = cpu_to_le32(offset);
		mb->checksum = cpu_to_le32(crc32c_le(log->uuid_checksum,
		mb->checksum = cpu_to_le32(crc32c(log->uuid_checksum,
						  mb, PAGE_SIZE));
		sync_page_io(log->rdev, ctx->pos, PAGE_SIZE, page,
			     REQ_OP_WRITE | REQ_SYNC | REQ_FUA, false);
@@ -2885,7 +2884,7 @@ int r5c_cache_data(struct r5l_log *log, struct stripe_head *sh)
		if (!test_bit(R5_Wantwrite, &sh->dev[i].flags))
			continue;
		addr = kmap_local_page(sh->dev[i].page);
		sh->dev[i].log_checksum = crc32c_le(log->uuid_checksum,
		sh->dev[i].log_checksum = crc32c(log->uuid_checksum,
						 addr, PAGE_SIZE);
		kunmap_local(addr);
		pages++;
@@ -2969,7 +2968,7 @@ static int r5l_load_log(struct r5l_log *log)
	}
	stored_crc = le32_to_cpu(mb->checksum);
	mb->checksum = 0;
	expected_crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE);
	expected_crc = crc32c(log->uuid_checksum, mb, PAGE_SIZE);
	if (stored_crc != expected_crc) {
		create_super = true;
		goto create;
@@ -3077,7 +3076,7 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
		return -ENOMEM;
	log->rdev = rdev;
	log->need_cache_flush = bdev_write_cache(rdev->bdev);
	log->uuid_checksum = crc32c_le(~0, rdev->mddev->uuid,
	log->uuid_checksum = crc32c(~0, rdev->mddev->uuid,
				    sizeof(rdev->mddev->uuid));

	mutex_init(&log->io_mutex);
+8 −8
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ static int ppl_log_stripe(struct ppl_log *log, struct stripe_head *sh)
	if (!test_bit(STRIPE_FULL_WRITE, &sh->state)) {
		le32_add_cpu(&e->pp_size, PAGE_SIZE);
		io->pp_size += PAGE_SIZE;
		e->checksum = cpu_to_le32(crc32c_le(le32_to_cpu(e->checksum),
		e->checksum = cpu_to_le32(crc32c(le32_to_cpu(e->checksum),
						 page_address(sh->ppl_page),
						 PAGE_SIZE));
	}
@@ -454,7 +454,7 @@ static void ppl_submit_iounit(struct ppl_io_unit *io)
	}

	pplhdr->entries_count = cpu_to_le32(io->entries_count);
	pplhdr->checksum = cpu_to_le32(~crc32c_le(~0, pplhdr, PPL_HEADER_SIZE));
	pplhdr->checksum = cpu_to_le32(~crc32c(~0, pplhdr, PPL_HEADER_SIZE));

	/* Rewind the buffer if current PPL is larger then remaining space */
	if (log->use_multippl &&
@@ -998,7 +998,7 @@ static int ppl_recover(struct ppl_log *log, struct ppl_header *pplhdr,
				goto out;
			}

			crc = crc32c_le(crc, page_address(page), s);
			crc = crc32c(crc, page_address(page), s);

			pp_size -= s;
			sector += s >> 9;
@@ -1052,7 +1052,7 @@ static int ppl_write_empty_header(struct ppl_log *log)
			    log->rdev->ppl.size, GFP_NOIO, 0);
	memset(pplhdr->reserved, 0xff, PPL_HDR_RESERVED);
	pplhdr->signature = cpu_to_le32(log->ppl_conf->signature);
	pplhdr->checksum = cpu_to_le32(~crc32c_le(~0, pplhdr, PAGE_SIZE));
	pplhdr->checksum = cpu_to_le32(~crc32c(~0, pplhdr, PAGE_SIZE));

	if (!sync_page_io(rdev, rdev->ppl.sector - rdev->data_offset,
			  PPL_HEADER_SIZE, page, REQ_OP_WRITE | REQ_SYNC |
@@ -1106,7 +1106,7 @@ static int ppl_load_distributed(struct ppl_log *log)
		/* check header validity */
		crc_stored = le32_to_cpu(pplhdr->checksum);
		pplhdr->checksum = 0;
		crc = ~crc32c_le(~0, pplhdr, PAGE_SIZE);
		crc = ~crc32c(~0, pplhdr, PAGE_SIZE);

		if (crc_stored != crc) {
			pr_debug("%s: ppl header crc does not match: stored: 0x%x calculated: 0x%x (offset: %llu)\n",
@@ -1390,7 +1390,7 @@ int ppl_init_log(struct r5conf *conf)
	spin_lock_init(&ppl_conf->no_mem_stripes_lock);

	if (!mddev->external) {
		ppl_conf->signature = ~crc32c_le(~0, mddev->uuid, sizeof(mddev->uuid));
		ppl_conf->signature = ~crc32c(~0, mddev->uuid, sizeof(mddev->uuid));
		ppl_conf->block_size = 512;
	} else {
		ppl_conf->block_size =
+1 −1
Original line number Diff line number Diff line
@@ -2593,7 +2593,7 @@ void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
/********************* Multicast verbs: SET, CLEAR ****************************/
static inline u8 bnx2x_mcast_bin_from_mac(u8 *mac)
{
	return (crc32c_le(0, mac, ETH_ALEN) >> 24) & 0xff;
	return (crc32c(0, mac, ETH_ALEN) >> 24) & 0xff;
}

struct bnx2x_mcast_mac_elem {
Loading