aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2012-05-02 13:14:56 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-05-14 00:21:35 -0400
commite47f3db4587c5486d3d5838fd4bef4f9c3b12205 (patch)
tree91e33fd230cf2ea89dddd90db9ea077f0c93f4e3 /drivers/mtd
parent1fbb938dff5b6bb4514a4e7600276b03c7f08e25 (diff)
mtd: nand: pass proper 'oob_required' parameter
We now have an interface for notifying the nand_ecc_ctrl functions when OOB data must be returned to the upper layers and when it may be left untouched. This patch fills in the 'oob_required' parameter properly from nand_do_{read,write}_ops. When utilized properly in the lower layers, this parameter can improve performance and/or reduce complexity for NAND HW and SW that can simply avoid transferring the OOB data. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com> Acked-by: Jiandong Zheng <jdzheng@broadcom.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/nand_base.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 6d4894acb567..464b742431ed 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1480,7 +1480,7 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
1480static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, 1480static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
1481 struct mtd_oob_ops *ops) 1481 struct mtd_oob_ops *ops)
1482{ 1482{
1483 int chipnr, page, realpage, col, bytes, aligned; 1483 int chipnr, page, realpage, col, bytes, aligned, oob_required;
1484 struct nand_chip *chip = mtd->priv; 1484 struct nand_chip *chip = mtd->priv;
1485 struct mtd_ecc_stats stats; 1485 struct mtd_ecc_stats stats;
1486 int ret = 0; 1486 int ret = 0;
@@ -1504,6 +1504,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
1504 1504
1505 buf = ops->datbuf; 1505 buf = ops->datbuf;
1506 oob = ops->oobbuf; 1506 oob = ops->oobbuf;
1507 oob_required = oob ? 1 : 0;
1507 1508
1508 while (1) { 1509 while (1) {
1509 bytes = min(mtd->writesize - col, readlen); 1510 bytes = min(mtd->writesize - col, readlen);
@@ -1521,13 +1522,14 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
1521 */ 1522 */
1522 if (unlikely(ops->mode == MTD_OPS_RAW)) 1523 if (unlikely(ops->mode == MTD_OPS_RAW))
1523 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi, 1524 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi,
1524 1, page); 1525 oob_required,
1526 page);
1525 else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob) 1527 else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
1526 ret = chip->ecc.read_subpage(mtd, chip, 1528 ret = chip->ecc.read_subpage(mtd, chip,
1527 col, bytes, bufpoi); 1529 col, bytes, bufpoi);
1528 else 1530 else
1529 ret = chip->ecc.read_page(mtd, chip, bufpoi, 1531 ret = chip->ecc.read_page(mtd, chip, bufpoi,
1530 1, page); 1532 oob_required, page);
1531 if (ret < 0) { 1533 if (ret < 0) {
1532 if (!aligned) 1534 if (!aligned)
1533 /* Invalidate page cache */ 1535 /* Invalidate page cache */
@@ -1554,7 +1556,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
1554 buf += bytes; 1556 buf += bytes;
1555 1557
1556 if (unlikely(oob)) { 1558 if (unlikely(oob)) {
1557
1558 int toread = min(oobreadlen, max_oobsize); 1559 int toread = min(oobreadlen, max_oobsize);
1559 1560
1560 if (toread) { 1561 if (toread) {
@@ -2213,6 +2214,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
2213 uint8_t *oob = ops->oobbuf; 2214 uint8_t *oob = ops->oobbuf;
2214 uint8_t *buf = ops->datbuf; 2215 uint8_t *buf = ops->datbuf;
2215 int ret, subpage; 2216 int ret, subpage;
2217 int oob_required = oob ? 1 : 0;
2216 2218
2217 ops->retlen = 0; 2219 ops->retlen = 0;
2218 if (!writelen) 2220 if (!writelen)
@@ -2275,8 +2277,8 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
2275 memset(chip->oob_poi, 0xff, mtd->oobsize); 2277 memset(chip->oob_poi, 0xff, mtd->oobsize);
2276 } 2278 }
2277 2279
2278 ret = chip->write_page(mtd, chip, wbuf, 1, page, cached, 2280 ret = chip->write_page(mtd, chip, wbuf, oob_required, page,
2279 (ops->mode == MTD_OPS_RAW)); 2281 cached, (ops->mode == MTD_OPS_RAW));
2280 if (ret) 2282 if (ret)
2281 break; 2283 break;
2282 2284