From: Eric Biggers Date: Fri, 6 Feb 2026 04:59:32 +0000 (-0800) Subject: dm-verity-fec: simplify computation of rsb X-Git-Tag: v7.1-rc1~148^2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ef45923fdcb7ec44e3a965bcbf41723e20814e4;p=thirdparty%2Flinux.git dm-verity-fec: simplify computation of rsb To compute 'rsb', verity_fec_decode() divides 'offset' by 'v->fec->region_blocks << v->data_dev_block_bits', then subtracts the quotient times that divisor. That's simply the long way to do a modulo operation, i.e. a - b * floor(a / b) instead of just a % b. Use div64_u64_rem() to get the remainder more concisely. Signed-off-by: Eric Biggers Signed-off-by: Mikulas Patocka --- diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c index d132fd5dc7b43..d2c55896e6f70 100644 --- a/drivers/md/dm-verity-fec.c +++ b/drivers/md/dm-verity-fec.c @@ -377,7 +377,7 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io, { int r; struct dm_verity_fec_io *fio; - u64 offset, res, rsb; + u64 offset, rsb; if (!verity_fec_is_enabled(v)) return -EOPNOTSUPP; @@ -405,13 +405,13 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io, */ offset = block << v->data_dev_block_bits; - res = div64_u64(offset, v->fec->region_blocks << v->data_dev_block_bits); /* * The base RS block we can feed to the interleaver to find out all * blocks required for decoding. */ - rsb = offset - res * (v->fec->region_blocks << v->data_dev_block_bits); + div64_u64_rem(offset, v->fec->region_blocks << v->data_dev_block_bits, + &rsb); /* * Locating erasures is slow, so attempt to recover the block without