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

mtd: docg3: switch to mtd_ooblayout_ops

Replace the nand_ecclayout definition by the equivalent mtd_ooblayout_ops
definition.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

+35 -11
+35 -11
drivers/mtd/devices/docg3.c
··· 67 67 MODULE_PARM_DESC(reliable_mode, "Set the docg3 mode (0=normal MLC, 1=fast, " 68 68 "2=reliable) : MLC normal operations are in normal mode"); 69 69 70 - /** 71 - * struct docg3_oobinfo - DiskOnChip G3 OOB layout 72 - * @eccbytes: 8 bytes are used (1 for Hamming ECC, 7 for BCH ECC) 73 - * @eccpos: ecc positions (byte 7 is Hamming ECC, byte 8-14 are BCH ECC) 74 - * @oobfree: free pageinfo bytes (byte 0 until byte 6, byte 15 75 - */ 76 - static struct nand_ecclayout docg3_oobinfo = { 77 - .eccbytes = 8, 78 - .eccpos = {7, 8, 9, 10, 11, 12, 13, 14}, 79 - .oobfree = {{0, 7}, {15, 1} }, 70 + static int docg3_ooblayout_ecc(struct mtd_info *mtd, int section, 71 + struct mtd_oob_region *oobregion) 72 + { 73 + if (section) 74 + return -ERANGE; 75 + 76 + /* byte 7 is Hamming ECC, byte 8-14 are BCH ECC */ 77 + oobregion->offset = 7; 78 + oobregion->length = 8; 79 + 80 + return 0; 81 + } 82 + 83 + static int docg3_ooblayout_free(struct mtd_info *mtd, int section, 84 + struct mtd_oob_region *oobregion) 85 + { 86 + if (section > 1) 87 + return -ERANGE; 88 + 89 + /* free bytes: byte 0 until byte 6, byte 15 */ 90 + if (!section) { 91 + oobregion->offset = 0; 92 + oobregion->length = 7; 93 + } else { 94 + oobregion->offset = 15; 95 + oobregion->length = 1; 96 + } 97 + 98 + return 0; 99 + } 100 + 101 + static const struct mtd_ooblayout_ops nand_ooblayout_docg3_ops = { 102 + .ecc = docg3_ooblayout_ecc, 103 + .free = docg3_ooblayout_free, 80 104 }; 81 105 82 106 static inline u8 doc_readb(struct docg3 *docg3, u16 reg) ··· 1881 1857 mtd->_read_oob = doc_read_oob; 1882 1858 mtd->_write_oob = doc_write_oob; 1883 1859 mtd->_block_isbad = doc_block_isbad; 1884 - mtd_set_ecclayout(mtd, &docg3_oobinfo); 1860 + mtd_set_ooblayout(mtd, &nand_ooblayout_docg3_ops); 1885 1861 mtd->oobavail = 8; 1886 1862 mtd->ecc_strength = DOC_ECC_BCH_T; 1887 1863