Skip to content

Commit 1bd0b24

Browse files
author
Boris Brezillon
committed
mtd: docg3: switch to mtd_ooblayout_ops
Replace the nand_ecclayout definition by the equivalent mtd_ooblayout_ops definition. Signed-off-by: Boris Brezillon <[email protected]> Acked-by: Robert Jarzmik <[email protected]>
1 parent adbbc3b commit 1bd0b24

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

drivers/mtd/devices/docg3.c

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,40 @@ module_param(reliable_mode, uint, 0);
6767
MODULE_PARM_DESC(reliable_mode, "Set the docg3 mode (0=normal MLC, 1=fast, "
6868
"2=reliable) : MLC normal operations are in normal mode");
6969

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,
80104
};
81105

82106
static inline u8 doc_readb(struct docg3 *docg3, u16 reg)
@@ -1857,7 +1881,7 @@ static int __init doc_set_driver_info(int chip_id, struct mtd_info *mtd)
18571881
mtd->_read_oob = doc_read_oob;
18581882
mtd->_write_oob = doc_write_oob;
18591883
mtd->_block_isbad = doc_block_isbad;
1860-
mtd_set_ecclayout(mtd, &docg3_oobinfo);
1884+
mtd_set_ooblayout(mtd, &nand_ooblayout_docg3_ops);
18611885
mtd->oobavail = 8;
18621886
mtd->ecc_strength = DOC_ECC_BCH_T;
18631887

0 commit comments

Comments
 (0)