[openwrt/openwrt] kernel: nmbm: add mediatek,bmt-mtd-overridden-oobsize property

LEDE Commits lede-commits at lists.infradead.org
Fri Feb 7 00:04:39 PST 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/e585ae70d4f2a563b3b0e430e15ee19ad25caeb5

commit e585ae70d4f2a563b3b0e430e15ee19ad25caeb5
Author: Mikhail Zhilkin <csharper2005 at gmail.com>
AuthorDate: Tue Feb 4 15:55:08 2025 +0000

    kernel: nmbm: add mediatek,bmt-mtd-overridden-oobsize property
    
    This commit adds new "mediatek,bmt-mtd-overridden-oobsize" property. The
    property helps avoid "NMBM configuration mismatch" error if mtd "OOB size"
    is not equal to the "spare size" which is stored in the nmbm signature.
    
    Signed-off-by: Mikhail Zhilkin <csharper2005 at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/17549
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 target/linux/generic/files/drivers/mtd/nand/mtk_bmt.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/target/linux/generic/files/drivers/mtd/nand/mtk_bmt.c b/target/linux/generic/files/drivers/mtd/nand/mtk_bmt.c
index bcff7d6ac8..063adb50fb 100644
--- a/target/linux/generic/files/drivers/mtd/nand/mtk_bmt.c
+++ b/target/linux/generic/files/drivers/mtd/nand/mtk_bmt.c
@@ -407,6 +407,7 @@ int mtk_bmt_attach(struct mtd_info *mtd)
 {
 	struct device_node *np;
 	int ret = 0;
+	u32 overridden_oobsize = 0;
 
 	if (bmtd.mtd)
 		return -ENOSPC;
@@ -431,6 +432,14 @@ int mtk_bmt_attach(struct mtd_info *mtd)
 	bmtd.mtd = mtd;
 	mtk_bmt_replace_ops(mtd);
 
+	if (!of_property_read_u32(np, "mediatek,bmt-mtd-overridden-oobsize",
+				  &overridden_oobsize))
+		if (overridden_oobsize < bmtd.mtd->oobsize) {
+			bmtd.mtd->oobsize = overridden_oobsize;
+			pr_info("NMBM: mtd OOB size has been overridden to %luB\n",
+				(long unsigned int)bmtd.mtd->oobsize);
+		}
+
 	bmtd.blk_size = mtd->erasesize;
 	bmtd.blk_shift = ffs(bmtd.blk_size) - 1;
 	bmtd.pg_size = mtd->writesize;




More information about the lede-commits mailing list