Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: mxc_nand: generate nand_ecclayout for 8 bit ECC

Hardware 8 bit ECC requires a different nand_ecclayout. Instead of adding yet
another static struct nand_ecclayout, generate it in code.

Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Baruch Siach and committed by
Brian Norris
8eeb4c52 c19900ed

+21 -1
+21 -1
drivers/mtd/nand/mxc_nand.c
··· 960 960 return 8; 961 961 } 962 962 963 + static void ecc_8bit_layout_4k(struct nand_ecclayout *layout) 964 + { 965 + int i, j; 966 + 967 + layout->eccbytes = 8*18; 968 + for (i = 0; i < 8; i++) 969 + for (j = 0; j < 18; j++) 970 + layout->eccpos[i*18 + j] = i*26 + j + 7; 971 + 972 + layout->oobfree[0].offset = 2; 973 + layout->oobfree[0].length = 4; 974 + for (i = 1; i < 8; i++) { 975 + layout->oobfree[i].offset = i*26; 976 + layout->oobfree[i].length = 7; 977 + } 978 + } 979 + 963 980 static void preset_v1(struct mtd_info *mtd) 964 981 { 965 982 struct nand_chip *nand_chip = mtd->priv; ··· 1653 1636 1654 1637 if (mtd->writesize == 2048) 1655 1638 this->ecc.layout = host->devtype_data->ecclayout_2k; 1656 - else if (mtd->writesize == 4096) 1639 + else if (mtd->writesize == 4096) { 1657 1640 this->ecc.layout = host->devtype_data->ecclayout_4k; 1641 + if (get_eccsize(mtd) == 8) 1642 + ecc_8bit_layout_4k(this->ecc.layout); 1643 + } 1658 1644 1659 1645 /* 1660 1646 * Experimentation shows that i.MX NFC can only handle up to 218 oob