kernel: mtk_bmt: fix block copying on remap with bmt v2
authorFelix Fietkau <nbd@nbd.name>
Wed, 9 Mar 2022 15:04:39 +0000 (16:04 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 25 Mar 2022 20:11:09 +0000 (21:11 +0100)
Copy from the previously mapped block (in case it was remapped already)

Signed-off-by: Felix Fietkau <nbd@nbd.name>
target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c

index f2dc05be2bc475dc1799216374dcda8d114a3137..2770376e98bb14b6d468bad14954e08cd4e5d20f 100644 (file)
@@ -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);