mtd: atmel_nand: add a definition for the oob reserved bytes

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Apr 22 10:59:07 PDT 2015


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=477478aedc8bdf1925785835609bc7e790f69aef
Commit:     477478aedc8bdf1925785835609bc7e790f69aef
Parent:     3a434f66e6dab645d74a59c95651cdbe16497a50
Author:     Josh Wu <josh.wu at atmel.com>
AuthorDate: Thu Apr 2 14:12:33 2015 +0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Sun Apr 5 17:47:56 2015 -0700

    mtd: atmel_nand: add a definition for the oob reserved bytes
    
    It's better to use a macro instead of just a number.
    
    Signed-off-by: Josh Wu <josh.wu at atmel.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/atmel_nand.c     | 5 +++--
 drivers/mtd/nand/atmel_nand_ecc.h | 3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index feaac90..0361c19 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -485,7 +485,7 @@ static void pmecc_config_ecc_layout(struct nand_ecclayout *layout,
 	for (i = 0; i < ecc_len; i++)
 		layout->eccpos[i] = oobsize - ecc_len + i;
 
-	layout->oobfree[0].offset = 2;
+	layout->oobfree[0].offset = PMECC_OOB_RESERVED_BYTES;
 	layout->oobfree[0].length =
 		oobsize - ecc_len - layout->oobfree[0].offset;
 }
@@ -1254,7 +1254,8 @@ static int atmel_pmecc_nand_init_params(struct platform_device *pdev,
 		nand_chip->ecc.steps = mtd->writesize / sector_size;
 		nand_chip->ecc.total = nand_chip->ecc.bytes *
 			nand_chip->ecc.steps;
-		if (nand_chip->ecc.total > mtd->oobsize - 2) {
+		if (nand_chip->ecc.total >
+				mtd->oobsize - PMECC_OOB_RESERVED_BYTES) {
 			dev_err(host->dev, "No room for ECC bytes\n");
 			err_no = -EINVAL;
 			goto err;
diff --git a/drivers/mtd/nand/atmel_nand_ecc.h b/drivers/mtd/nand/atmel_nand_ecc.h
index d4035e3..668e735 100644
--- a/drivers/mtd/nand/atmel_nand_ecc.h
+++ b/drivers/mtd/nand/atmel_nand_ecc.h
@@ -152,4 +152,7 @@
 /* Time out value for reading PMECC status register */
 #define PMECC_MAX_TIMEOUT_MS			100
 
+/* Reserved bytes in oob area */
+#define PMECC_OOB_RESERVED_BYTES		2
+
 #endif



More information about the linux-mtd-cvs mailing list