drivers: rkflash: Fix error in counting BITS_PER_LONG

Change-Id: I3a76a3a5003fcfcd7c079fd83d67f7161a85708a
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
Jon Lin
2020-06-14 18:55:35 +08:00
committed by Tao Huang
parent 56fe1c4cfe
commit 57d30184ca

View File

@@ -42,7 +42,7 @@ static int nanddev_read_bbt(struct snand_mtd_dev *nand, u32 block, bool update)
unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
unsigned int nblocks = snanddev_neraseblocks(nand);
unsigned int nbytes = DIV_ROUND_UP(nblocks * bits_per_block,
BITS_PER_LONG) * 4;
BITS_PER_LONG) * sizeof(*nand->bbt.cache);
struct mtd_info *mtd = snanddev_to_mtd(nand);
u8 *data_buf, *oob_buf;
struct nanddev_bbt_info *bbt_info;
@@ -112,7 +112,7 @@ static int nanddev_write_bbt(struct snand_mtd_dev *nand, u32 block)
unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
unsigned int nblocks = snanddev_neraseblocks(nand);
unsigned int nbytes = DIV_ROUND_UP(nblocks * bits_per_block,
BITS_PER_LONG) * 4;
BITS_PER_LONG) * sizeof(*nand->bbt.cache);
struct mtd_info *mtd = snanddev_to_mtd(nand);
u8 *data_buf, *oob_buf;
struct nanddev_bbt_info *bbt_info;
@@ -383,8 +383,8 @@ int snanddev_bbt_set_block_status(struct snand_mtd_dev *nand,
if (entry >= snanddev_neraseblocks(nand))
return -ERANGE;
if (offs + bits_per_block - 1 > 31)
pos[0] &= ~GENMASK(31, offs);
if (offs + bits_per_block - 1 > (BITS_PER_LONG - 1))
pos[0] &= ~GENMASK(BITS_PER_LONG - 1, offs);
else
pos[0] &= ~GENMASK(offs + bits_per_block - 1, offs);
pos[0] |= val << offs;