@@ -67,16 +67,40 @@ module_param(reliable_mode, uint, 0);
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 )
@@ -1857,7 +1881,7 @@ static int __init doc_set_driver_info(int chip_id, struct mtd_info *mtd)
1857
1881
mtd -> _read_oob = doc_read_oob ;
1858
1882
mtd -> _write_oob = doc_write_oob ;
1859
1883
mtd -> _block_isbad = doc_block_isbad ;
1860
- mtd_set_ecclayout (mtd , & docg3_oobinfo );
1884
+ mtd_set_ooblayout (mtd , & nand_ooblayout_docg3_ops );
1861
1885
mtd -> oobavail = 8 ;
1862
1886
mtd -> ecc_strength = DOC_ECC_BCH_T ;
1863
1887
0 commit comments