diff options
author | Shmulik Ladkani <shmulik.ladkani@gmail.com> | 2012-05-09 06:13:34 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-05-14 00:25:00 -0400 |
commit | 1951f2f710a621ae0bc4268617046a6c02c634d0 (patch) | |
tree | e39850855d7a3062666592736c4e19c1bd4104f5 /drivers | |
parent | 5c2ffb11d40dd967eecb45b8570a871746ba124b (diff) |
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: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 13 |
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; |