From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pz0-f43.google.com ([209.85.210.43]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SJuXW-0001pd-NQ for linux-mtd@lists.infradead.org; Mon, 16 Apr 2012 22:36:56 +0000 Received: by dadn15 with SMTP id n15so9114789dad.16 for ; Mon, 16 Apr 2012 15:36:54 -0700 (PDT) From: Brian Norris To: Subject: [PATCH 2/2] mtd: nand: nand_do_{read, write}_ops - pass OOB buffer through Date: Mon, 16 Apr 2012 15:35:55 -0700 Message-Id: <1334615755-15418-3-git-send-email-computersforpeace@gmail.com> In-Reply-To: <1334615755-15418-1-git-send-email-computersforpeace@gmail.com> References: <1334615755-15418-1-git-send-email-computersforpeace@gmail.com> Cc: Viresh Kumar , Artem Bityutskiy , Nicolas Ferre , Vipin Kumar , Laurent Pinchart , Florian Fainelli , Jamie Iles , Mike Dunn , Bastian Hecht , Dmitry Eremin-Solenikov , Kevin Cernekee , Lei Wen , Axel Lin , Li Yang , Jean-Christophe PLAGNIOL-VILLARD , Armando Visconti , Liu Shuo , Thomas Gleixner , Scott Branden , Artem Bityutskiy , Wolfram Sang , Huang Shijie , Shmulik Ladkani , Jiandong Zheng , Brian Norris , David Woodhouse List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 --- 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