Commit e47f3db4 authored by Brian Norris's avatar Brian Norris Committed by David Woodhouse

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: default avatarBrian Norris <computersforpeace@gmail.com>
Reviewed-by: default avatarShmulik Ladkani <shmulik.ladkani@gmail.com>
Acked-by: default avatarJiandong Zheng <jdzheng@broadcom.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 1fbb938d
...@@ -1480,7 +1480,7 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob, ...@@ -1480,7 +1480,7 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops) struct mtd_oob_ops *ops)
{ {
int chipnr, page, realpage, col, bytes, aligned; int chipnr, page, realpage, col, bytes, aligned, oob_required;
struct nand_chip *chip = mtd->priv; struct nand_chip *chip = mtd->priv;
struct mtd_ecc_stats stats; struct mtd_ecc_stats stats;
int ret = 0; int ret = 0;
...@@ -1504,6 +1504,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, ...@@ -1504,6 +1504,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
buf = ops->datbuf; buf = ops->datbuf;
oob = ops->oobbuf; oob = ops->oobbuf;
oob_required = oob ? 1 : 0;
while (1) { while (1) {
bytes = min(mtd->writesize - col, readlen); bytes = min(mtd->writesize - col, readlen);
...@@ -1521,13 +1522,14 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, ...@@ -1521,13 +1522,14 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
*/ */
if (unlikely(ops->mode == MTD_OPS_RAW)) if (unlikely(ops->mode == MTD_OPS_RAW))
ret = chip->ecc.read_page_raw(mtd, chip, bufpoi, ret = chip->ecc.read_page_raw(mtd, chip, bufpoi,
1, page); oob_required,
page);
else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob) else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
ret = chip->ecc.read_subpage(mtd, chip, ret = chip->ecc.read_subpage(mtd, chip,
col, bytes, bufpoi); col, bytes, bufpoi);
else else
ret = chip->ecc.read_page(mtd, chip, bufpoi, ret = chip->ecc.read_page(mtd, chip, bufpoi,
1, page); oob_required, page);
if (ret < 0) { if (ret < 0) {
if (!aligned) if (!aligned)
/* Invalidate page cache */ /* Invalidate page cache */
...@@ -1554,7 +1556,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, ...@@ -1554,7 +1556,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
buf += bytes; buf += bytes;
if (unlikely(oob)) { if (unlikely(oob)) {
int toread = min(oobreadlen, max_oobsize); int toread = min(oobreadlen, max_oobsize);
if (toread) { if (toread) {
...@@ -2213,6 +2214,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, ...@@ -2213,6 +2214,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
uint8_t *oob = ops->oobbuf; uint8_t *oob = ops->oobbuf;
uint8_t *buf = ops->datbuf; uint8_t *buf = ops->datbuf;
int ret, subpage; int ret, subpage;
int oob_required = oob ? 1 : 0;
ops->retlen = 0; ops->retlen = 0;
if (!writelen) if (!writelen)
...@@ -2275,8 +2277,8 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, ...@@ -2275,8 +2277,8 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
memset(chip->oob_poi, 0xff, mtd->oobsize); memset(chip->oob_poi, 0xff, mtd->oobsize);
} }
ret = chip->write_page(mtd, chip, wbuf, 1, page, cached, ret = chip->write_page(mtd, chip, wbuf, oob_required, page,
(ops->mode == MTD_OPS_RAW)); cached, (ops->mode == MTD_OPS_RAW));
if (ret) if (ret)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment