[PATCH 2/2] mtd: nand: nand_do_{read, write}_ops - pass OOB buffer through

Brian Norris computersforpeace at gmail.com
Mon Apr 16 18:35:55 EDT 2012


Now that we have a function parameter for the OOB buffer, we can pass the OOB
buffer as an argument to the nand_ecc_ctrl functions. This allows drivers to
know when OOB data must be returned to the upper layers and when it is simply
needed for internal calculations, potentially saving time for NAND HW/SW that
can simply avoid reading the OOB data.

Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/nand_base.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 95ba987..a206f43 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1475,7 +1475,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 	uint32_t max_oobsize = ops->mode == MTD_OPS_AUTO_OOB ?
 		mtd->oobavail : mtd->oobsize;
 
-	uint8_t *bufpoi, *oob, *buf;
+	uint8_t *bufpoi, *oobpoi, *oob, *buf;
 
 	stats = mtd->ecc_stats;
 
@@ -1489,6 +1489,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
 	buf = ops->datbuf;
 	oob = ops->oobbuf;
+	oobpoi = oob ? chip->oob_poi : NULL;
 
 	while (1) {
 		bytes = min(mtd->writesize - col, readlen);
@@ -1506,13 +1507,13 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 			/* Now read the page into the buffer */
 			if (unlikely(ops->mode == MTD_OPS_RAW))
 				ret = chip->ecc.read_page_raw(mtd, chip, bufpoi,
-							      NULL, page);
+							      oobpoi, page);
 			else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
 				ret = chip->ecc.read_subpage(mtd, chip,
 							col, bytes, bufpoi);
 			else
 				ret = chip->ecc.read_page(mtd, chip, bufpoi,
-							  NULL, page);
+							  oobpoi, page);
 			if (ret < 0) {
 				if (!aligned)
 					/* Invalidate page cache */
@@ -1535,7 +1536,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 			buf += bytes;
 
 			if (unlikely(oob)) {
-
 				int toread = min(oobreadlen, max_oobsize);
 
 				if (toread) {
@@ -2256,7 +2256,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 	while (1) {
 		int bytes = mtd->writesize;
 		int cached = writelen > bytes && page != blockmask;
-		uint8_t *wbuf = buf;
+		uint8_t *wbuf = buf, *oobpoi;
 
 		/* Partial page write? */
 		if (unlikely(column || writelen < (mtd->writesize - 1))) {
@@ -2272,12 +2272,14 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 			size_t len = min(oobwritelen, oobmaxlen);
 			oob = nand_fill_oob(mtd, oob, len, ops);
 			oobwritelen -= len;
+			oobpoi = chip->oob_poi;
 		} else {
+			oobpoi = NULL;
 			/* We still need to erase leftover OOB data */
 			memset(chip->oob_poi, 0xff, mtd->oobsize);
 		}
 
-		ret = chip->write_page(mtd, chip, wbuf, NULL, page, cached,
+		ret = chip->write_page(mtd, chip, wbuf, oobpoi, page, cached,
 				       (ops->mode == MTD_OPS_RAW));
 		if (ret)
 			break;
-- 
1.7.5.4.2.g519b1




More information about the linux-mtd mailing list