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@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/17549
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Mikhail Zhilkin 2025-02-04 15:55:08 +00:00 committed by Robert Marko
parent 98d7f4202f
commit e585ae70d4

View File

@ -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;