mtd: nand: bbt: Fix error in BBT block location methord

Avoid the high 32btis input param of GENMASK bigger then BITS_PER_LONG.

For example offs 62, bits_per_block 3, and BITS_PER_LONG 64, then:
GENMASK(offs + bits_per_block - 1, offs) -> GENMASK(64, 62) -> 0.
But actually we want to mask GENMASK(63, 62) which is equals to
0xc000000000000000.

Change-Id: Ie3ee89a4b3e3deca45ccf429bfdfc5b88e3e6b9c
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
Jon Lin
2021-09-08 20:02:21 +08:00
committed by Tao Huang
parent 7d408752e0
commit db0f003c66

View File

@@ -116,7 +116,10 @@ int nanddev_bbt_set_block_status(struct nand_device *nand, unsigned int entry,
if (entry >= nanddev_neraseblocks(nand))
return -ERANGE;
pos[0] &= ~GENMASK(offs + bits_per_block - 1, offs);
if (bits_per_block + offs > BITS_PER_LONG)
pos[0] &= ~GENMASK(BITS_PER_LONG - 1, offs);
else
pos[0] &= ~GENMASK(offs + bits_per_block - 1, offs);
pos[0] |= val << offs;
if (bits_per_block + offs > BITS_PER_LONG) {