diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-02-22 10:39:39 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-02-22 10:39:39 +0100 |
commit | 0299293b8d2a8546f1c72780ecb6511cf9ca3894 (patch) | |
tree | 205a840839abf7378ea4e8382861a76ba1dd89cb /drivers | |
parent | e59a93e1d5689ae174051f4179f3a8a283492f46 (diff) | |
parent | ce0733564d1a114ca649dc266f0c3321c4877c07 (diff) | |
download | barebox-0299293b8d2a8546f1c72780ecb6511cf9ca3894.tar.gz barebox-0299293b8d2a8546f1c72780ecb6511cf9ca3894.tar.xz |
Merge branch 'for-next/mtd'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/nand/bbt.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c index 172ab5ffbc..8a78f9046f 100644 --- a/drivers/mtd/nand/bbt.c +++ b/drivers/mtd/nand/bbt.c @@ -113,18 +113,20 @@ int nanddev_bbt_set_block_status(struct nand_device *nand, unsigned int entry, ((entry * bits_per_block) / BITS_PER_LONG); unsigned int offs = (entry * bits_per_block) % BITS_PER_LONG; unsigned long val = status & GENMASK(bits_per_block - 1, 0); + unsigned long shift = ((bits_per_block + offs <= BITS_PER_LONG) ? + (offs + bits_per_block - 1) : (BITS_PER_LONG - 1)); if (entry >= nanddev_neraseblocks(nand)) return -ERANGE; - pos[0] &= ~GENMASK(offs + bits_per_block - 1, offs); + pos[0] &= ~GENMASK(shift, offs); pos[0] |= val << offs; if (bits_per_block + offs > BITS_PER_LONG) { unsigned int rbits = bits_per_block + offs - BITS_PER_LONG; pos[1] &= ~GENMASK(rbits - 1, 0); - pos[1] |= val >> rbits; + pos[1] |= (val >> (BITS_PER_LONG - offs)); } return 0; |