[PATCH 1/3] mtd: nand: omap_gpmc: report available OOB bytes

Wagner Popov dos Santos <[email protected]>
Newsgroups gmane.comp.boot-loaders.u-boot.general,gmane.comp.boot-loaders.u-boot
Message-ID <dd41a5d2c229c146d42cae76cd1ff903d7be7a73.1787320113.git.wpopov@gmail.com>
The OMAP GPMC driver does not set oobavail for hardware ECC layouts.
As a result, the NAND core does not report any OOB space available for
automatic OOB operations such as JFFS2 cleanmarkers.

Set oobavail for all hardware ECC schemes after reserving ECC bytes and
the bad-block marker.

Signed-off-by: Wagner Popov dos Santos <[email protected]>
---
 drivers/mtd/nand/raw/omap_gpmc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mtd/nand/raw/omap_gpmc.c b/drivers/mtd/nand/raw/omap_gpmc.c
index 9c704c60e8e..0fbca6b9f27 100644
--- a/drivers/mtd/nand/raw/omap_gpmc.c
+++ b/drivers/mtd/nand/raw/omap_gpmc.c
@@ -873,6 +873,8 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
 		nand->ecc.calculate	= omap_calculate_ecc;
 		/* define ecc-layout */
 		ecclayout->eccbytes	= nand->ecc.bytes * eccsteps;
+		ecclayout->oobavail = oobsize - ecclayout->eccbytes -
+						BADBLOCK_MARKER_LENGTH;
 		for (i = 0; i < ecclayout->eccbytes; i++) {
 			if (nand->options & NAND_BUSWIDTH_16)
 				ecclayout->eccpos[i] = i + 2;
@@ -912,6 +914,8 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
 		/* define ecc-layout */
 		ecclayout->eccbytes	= nand->ecc.bytes * eccsteps;
 		ecclayout->eccpos[0]	= BADBLOCK_MARKER_LENGTH;
+		ecclayout->oobavail = oobsize - ecclayout->eccbytes -
+						BADBLOCK_MARKER_LENGTH;
 		for (i = 1; i < ecclayout->eccbytes; i++) {
 			if (i % nand->ecc.bytes)
 				ecclayout->eccpos[i] =
@@ -954,6 +958,8 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
 		nand->ecc.steps		= eccsteps;
 		/* define ecc-layout */
 		ecclayout->eccbytes	= nand->ecc.bytes * eccsteps;
+		ecclayout->oobavail = oobsize - ecclayout->eccbytes -
+						BADBLOCK_MARKER_LENGTH;
 		for (i = 0; i < ecclayout->eccbytes; i++)
 			ecclayout->eccpos[i] = i + BADBLOCK_MARKER_LENGTH;
 		ecclayout->oobfree[0].offset = i + BADBLOCK_MARKER_LENGTH;
@@ -988,6 +994,8 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
 		nand->ecc.steps		= eccsteps;
 		/* define ecc-layout */
 		ecclayout->eccbytes	= nand->ecc.bytes * eccsteps;
+		ecclayout->oobavail = oobsize - ecclayout->eccbytes -
+						BADBLOCK_MARKER_LENGTH;
 		for (i = 0; i < ecclayout->eccbytes; i++)
 			ecclayout->eccpos[i] = i + BADBLOCK_MARKER_LENGTH;
 		ecclayout->oobfree[0].offset = i + BADBLOCK_MARKER_LENGTH;
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.