Commit 1951f2f7 authored by Shmulik Ladkani's avatar Shmulik Ladkani Committed by David Woodhouse

mtd: nand: check the return code of 'read_oob/read_oob_raw'

Apparently, there is an implementor of 'read_oob' which may return an
error inidication (e.g. docg4_read_oob may return -EIO).

Test the return value of 'read_oob/read_oob_raw', and if negative,
propagate the error, so it's returned by the '_read_oob' interface.
Signed-off-by: default avatarShmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 5c2ffb11
...@@ -1791,6 +1791,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, ...@@ -1791,6 +1791,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
int readlen = ops->ooblen; int readlen = ops->ooblen;
int len; int len;
uint8_t *buf = ops->oobbuf; uint8_t *buf = ops->oobbuf;
int ret = 0;
pr_debug("%s: from = 0x%08Lx, len = %i\n", pr_debug("%s: from = 0x%08Lx, len = %i\n",
__func__, (unsigned long long)from, readlen); __func__, (unsigned long long)from, readlen);
...@@ -1826,9 +1827,12 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, ...@@ -1826,9 +1827,12 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
while (1) { while (1) {
if (ops->mode == MTD_OPS_RAW) if (ops->mode == MTD_OPS_RAW)
chip->ecc.read_oob_raw(mtd, chip, page); ret = chip->ecc.read_oob_raw(mtd, chip, page);
else else
chip->ecc.read_oob(mtd, chip, page); ret = chip->ecc.read_oob(mtd, chip, page);
if (ret < 0)
break;
len = min(len, readlen); len = min(len, readlen);
buf = nand_transfer_oob(chip, buf, ops, len); buf = nand_transfer_oob(chip, buf, ops, len);
...@@ -1857,7 +1861,10 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, ...@@ -1857,7 +1861,10 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
} }
} }
ops->oobretlen = ops->ooblen; ops->oobretlen = ops->ooblen - readlen;
if (ret < 0)
return ret;
if (mtd->ecc_stats.failed - stats.failed) if (mtd->ecc_stats.failed - stats.failed)
return -EBADMSG; return -EBADMSG;
......
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