aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/nand/omap2.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index ef4190a02b7b..34ef941e3bfb 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1633,6 +1633,7 @@ static int omap_nand_probe(struct platform_device *pdev)
1633 int i; 1633 int i;
1634 dma_cap_mask_t mask; 1634 dma_cap_mask_t mask;
1635 unsigned sig; 1635 unsigned sig;
1636 unsigned oob_index;
1636 struct resource *res; 1637 struct resource *res;
1637 struct mtd_part_parser_data ppdata = {}; 1638 struct mtd_part_parser_data ppdata = {};
1638 1639
@@ -1826,9 +1827,11 @@ static int omap_nand_probe(struct platform_device *pdev)
1826 (mtd->writesize / 1827 (mtd->writesize /
1827 nand_chip->ecc.size); 1828 nand_chip->ecc.size);
1828 if (nand_chip->options & NAND_BUSWIDTH_16) 1829 if (nand_chip->options & NAND_BUSWIDTH_16)
1829 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1830 oob_index = BADBLOCK_MARKER_LENGTH;
1830 else 1831 else
1831 ecclayout->eccpos[0] = 1; 1832 oob_index = 1;
1833 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++)
1834 ecclayout->eccpos[i] = oob_index;
1832 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1835 ecclayout->oobfree->offset = ecclayout->eccpos[0] +
1833 ecclayout->eccbytes; 1836 ecclayout->eccbytes;
1834 break; 1837 break;
@@ -1847,7 +1850,12 @@ static int omap_nand_probe(struct platform_device *pdev)
1847 ecclayout->eccbytes = nand_chip->ecc.bytes * 1850 ecclayout->eccbytes = nand_chip->ecc.bytes *
1848 (mtd->writesize / 1851 (mtd->writesize /
1849 nand_chip->ecc.size); 1852 nand_chip->ecc.size);
1850 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1853 oob_index = BADBLOCK_MARKER_LENGTH;
1854 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++) {
1855 ecclayout->eccpos[i] = oob_index;
1856 if (((i + 1) % nand_chip->ecc.bytes) == 0)
1857 oob_index++;
1858 }
1851 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1859 ecclayout->oobfree->offset = ecclayout->eccpos[0] +
1852 ecclayout->eccbytes; 1860 ecclayout->eccbytes;
1853 /* software bch library is used for locating errors */ 1861 /* software bch library is used for locating errors */
@@ -1883,7 +1891,9 @@ static int omap_nand_probe(struct platform_device *pdev)
1883 ecclayout->eccbytes = nand_chip->ecc.bytes * 1891 ecclayout->eccbytes = nand_chip->ecc.bytes *
1884 (mtd->writesize / 1892 (mtd->writesize /
1885 nand_chip->ecc.size); 1893 nand_chip->ecc.size);
1886 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1894 oob_index = BADBLOCK_MARKER_LENGTH;
1895 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++)
1896 ecclayout->eccpos[i] = oob_index;
1887 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1897 ecclayout->oobfree->offset = ecclayout->eccpos[0] +
1888 ecclayout->eccbytes; 1898 ecclayout->eccbytes;
1889 /* This ECC scheme requires ELM H/W block */ 1899 /* This ECC scheme requires ELM H/W block */
@@ -1913,7 +1923,12 @@ static int omap_nand_probe(struct platform_device *pdev)
1913 ecclayout->eccbytes = nand_chip->ecc.bytes * 1923 ecclayout->eccbytes = nand_chip->ecc.bytes *
1914 (mtd->writesize / 1924 (mtd->writesize /
1915 nand_chip->ecc.size); 1925 nand_chip->ecc.size);
1916 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1926 oob_index = BADBLOCK_MARKER_LENGTH;
1927 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++) {
1928 ecclayout->eccpos[i] = oob_index;
1929 if (((i + 1) % nand_chip->ecc.bytes) == 0)
1930 oob_index++;
1931 }
1917 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1932 ecclayout->oobfree->offset = ecclayout->eccpos[0] +
1918 ecclayout->eccbytes; 1933 ecclayout->eccbytes;
1919 /* software bch library is used for locating errors */ 1934 /* software bch library is used for locating errors */
@@ -1956,7 +1971,9 @@ static int omap_nand_probe(struct platform_device *pdev)
1956 ecclayout->eccbytes = nand_chip->ecc.bytes * 1971 ecclayout->eccbytes = nand_chip->ecc.bytes *
1957 (mtd->writesize / 1972 (mtd->writesize /
1958 nand_chip->ecc.size); 1973 nand_chip->ecc.size);
1959 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1974 oob_index = BADBLOCK_MARKER_LENGTH;
1975 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++)
1976 ecclayout->eccpos[i] = oob_index;
1960 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1977 ecclayout->oobfree->offset = ecclayout->eccpos[0] +
1961 ecclayout->eccbytes; 1978 ecclayout->eccbytes;
1962 break; 1979 break;
@@ -1975,8 +1992,6 @@ static int omap_nand_probe(struct platform_device *pdev)
1975 /* populate remaining ECC layout data */ 1992 /* populate remaining ECC layout data */
1976 ecclayout->oobfree->length = mtd->oobsize - (BADBLOCK_MARKER_LENGTH + 1993 ecclayout->oobfree->length = mtd->oobsize - (BADBLOCK_MARKER_LENGTH +
1977 ecclayout->eccbytes); 1994 ecclayout->eccbytes);
1978 for (i = 1; i < ecclayout->eccbytes; i++)
1979 ecclayout->eccpos[i] = ecclayout->eccpos[0] + i;
1980 /* check if NAND device's OOB is enough to store ECC signatures */ 1995 /* check if NAND device's OOB is enough to store ECC signatures */
1981 if (mtd->oobsize < (ecclayout->eccbytes + BADBLOCK_MARKER_LENGTH)) { 1996 if (mtd->oobsize < (ecclayout->eccbytes + BADBLOCK_MARKER_LENGTH)) {
1982 pr_err("not enough OOB bytes required = %d, available=%d\n", 1997 pr_err("not enough OOB bytes required = %d, available=%d\n",