kernel: mtk-bmt: fix usage of _oob_read
authorChuanhong Guo <gch981213@gmail.com>
Sat, 21 Jan 2023 02:47:59 +0000 (10:47 +0800)
committerChuanhong Guo <gch981213@gmail.com>
Wed, 25 Jan 2023 15:45:14 +0000 (23:45 +0800)
_oob_read returns number of bitflips on success while
bbt_nand_read should return 0.

Fixes: 2d49e49b18 ("mediatek: bmt: use generic mtd api")
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
(cherry picked from commit f183ce35b8ea2fd991ac489fb223b09a1ecb4db0)

target/linux/generic/files/drivers/mtd/nand/mtk_bmt.h

index dff1f28c8171f47217692b8ba5807f102fc7c297..517ff7414f34abbb3ff0f7bc2512e7ae8517f3c2 100644 (file)
@@ -95,8 +95,14 @@ bbt_nand_read(u32 page, unsigned char *dat, int dat_len,
                .datbuf = dat,
                .len = dat_len,
        };
-
-       return bmtd._read_oob(bmtd.mtd, page << bmtd.pg_shift, &ops);
+       int ret;
+
+       ret = bmtd._read_oob(bmtd.mtd, page << bmtd.pg_shift, &ops);
+       if (ret < 0)
+               return ret;
+       if (ret)
+               pr_info("%s: %d bitflips\n", __func__, ret);
+       return 0;
 }
 
 static inline int bbt_nand_erase(u16 block)