aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/nand_base.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 4047d7c2fee6..d47586cf64ce 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1791,6 +1791,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
1791 int readlen = ops->ooblen; 1791 int readlen = ops->ooblen;
1792 int len; 1792 int len;
1793 uint8_t *buf = ops->oobbuf; 1793 uint8_t *buf = ops->oobbuf;
1794 int ret = 0;
1794 1795
1795 pr_debug("%s: from = 0x%08Lx, len = %i\n", 1796 pr_debug("%s: from = 0x%08Lx, len = %i\n",
1796 __func__, (unsigned long long)from, readlen); 1797 __func__, (unsigned long long)from, readlen);
@@ -1826,9 +1827,12 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
1826 1827
1827 while (1) { 1828 while (1) {
1828 if (ops->mode == MTD_OPS_RAW) 1829 if (ops->mode == MTD_OPS_RAW)
1829 chip->ecc.read_oob_raw(mtd, chip, page); 1830 ret = chip->ecc.read_oob_raw(mtd, chip, page);
1830 else 1831 else
1831 chip->ecc.read_oob(mtd, chip, page); 1832 ret = chip->ecc.read_oob(mtd, chip, page);
1833
1834 if (ret < 0)
1835 break;
1832 1836
1833 len = min(len, readlen); 1837 len = min(len, readlen);
1834 buf = nand_transfer_oob(chip, buf, ops, len); 1838 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 } 1861 }
1858 } 1862 }
1859 1863
1860 ops->oobretlen = ops->ooblen; 1864 ops->oobretlen = ops->ooblen - readlen;
1865
1866 if (ret < 0)
1867 return ret;
1861 1868
1862 if (mtd->ecc_stats.failed - stats.failed) 1869 if (mtd->ecc_stats.failed - stats.failed)
1863 return -EBADMSG; 1870 return -EBADMSG;