Skip to content

Commit

Permalink
kernel: mtk_bmt: fix block copying on remap with bmt v2
Browse files Browse the repository at this point in the history
Copy from the previously mapped block (in case it was remapped already)

Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 committed Mar 25, 2022
1 parent b4c7f8c commit 7d1e2be
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,21 @@ static u16 find_valid_block_in_pool(struct bbbt *bbt)
*/
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);

Expand Down

0 comments on commit 7d1e2be

Please sign in to comment.