diff mbox series

[2/2] nand: brcmnand: fix BBI in hamming oob layout

Message ID 20200504093034.2739968-2-noltari@gmail.com
State New
Headers show
Series None | expand

Commit Message

Álvaro Fernández Rojas May 4, 2020, 9:30 a.m. UTC
Small Page NAND uses byte 6 for BBI and Large Page NAND uses first 2 bytes.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 1bba309c7684..59c3241f4ea5 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -1109,10 +1109,18 @@  static int brcmnand_hamming_ooblayout_free(struct mtd_info *mtd, int section,
 	if (section < sectors)
 		next += 6;
 
-	if (section)
+	if (section) {
 		oobregion->offset = ((section - 1) * sas) + 9;
-	else
-		oobregion->offset = 1; /* BBI */
+	} else {
+		if (cfg->page_size == 512) {
+			/* small page uses byte 6 for BBI */
+			oobregion->offset = 0;
+			next--;
+		} else {
+			/* large page uses first 2 bytes for BBI */
+			oobregion->offset = 2;
+		}
+	}
 
 	oobregion->length = next - oobregion->offset;