aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2022-03-09 16:04:39 +0100
committerFelix Fietkau <nbd@nbd.name>2022-10-10 12:58:22 +0200
commita78fd5bbb62bdb20d075b7ab42d3f09ca465d550 (patch)
treea7f40de062c82ec5ca34485210522dcf23c077fe
parent0c21f06ef7544d7492537369b5c4c1ae3b87c935 (diff)
downloadupstream-a78fd5bbb62bdb20d075b7ab42d3f09ca465d550.tar.gz
upstream-a78fd5bbb62bdb20d075b7ab42d3f09ca465d550.tar.bz2
upstream-a78fd5bbb62bdb20d075b7ab42d3f09ca465d550.zip
kernel: mtk_bmt: fix block copying on remap with bmt v2
Copy from the previously mapped block (in case it was remapped already) Signed-off-by: Felix Fietkau <nbd@nbd.name> (cherry-picked from commit 7d1e2be1605eda85e1a607a3d3ddefed1b961d3d)
-rw-r--r--target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c b/target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c
index f2dc05be2b..2770376e98 100644
--- a/target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c
+++ b/target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c
@@ -285,21 +285,21 @@ error:
*/
static bool remap_block_v2(u16 block, u16 mapped_block, int copy_len)
{
- u16 mapped_blk;
+ u16 new_block;
struct bbbt *bbt;
bbt = bmtd.bbt;
- mapped_blk = find_valid_block_in_pool(bbt);
- if (mapped_blk == 0)
+ new_block = find_valid_block_in_pool(bbt);
+ if (new_block == 0)
return false;
/* Map new bad block to available block in pool */
- bbt->bb_tbl[block] = mapped_blk;
+ bbt->bb_tbl[block] = new_block;
/* Erase new block */
- bbt_nand_erase(mapped_blk);
+ bbt_nand_erase(new_block);
if (copy_len > 0)
- bbt_nand_copy(mapped_blk, block, copy_len);
+ bbt_nand_copy(new_block, mapped_block, copy_len);
bmtd.bmt_blk_idx = upload_bmt(bbt, bmtd.bmt_blk_idx);