aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-27 16:16:10 -0400
committerThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-29 09:06:50 -0400
commit5bd34c091a044d130601370c370f84b1c59f1627 (patch)
tree8b08012a9a30186a8805d506f8438e2944f5f31b /drivers/mtd/nand
parentff268fb8791cf18df536113355d7184007c269d9 (diff)
[MTD] NAND Replace oobinfo by ecclayout
The nand_oobinfo structure is not fitting the newer error correction demands anymore. Replace it by struct nand_ecclayout and fixup the users all over the place. Keep the nand_oobinfo based ioctl for user space compability reasons. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/diskonchip.c5
-rw-r--r--drivers/mtd/nand/nand_base.c52
-rw-r--r--drivers/mtd/nand/ndfc.c2
-rw-r--r--drivers/mtd/nand/rtc_from4.c5
-rw-r--r--drivers/mtd/nand/s3c2410.c5
-rw-r--r--drivers/mtd/nand/sharpsl.c5
6 files changed, 42 insertions, 32 deletions
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index 82262a4a4208..463e12ced1b3 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -1058,8 +1058,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat,
1058 * safer. The only problem with it is that any code that parses oobfree must 1058 * safer. The only problem with it is that any code that parses oobfree must
1059 * be able to handle out-of-order segments. 1059 * be able to handle out-of-order segments.
1060 */ 1060 */
1061static struct nand_oobinfo doc200x_oobinfo = { 1061static struct nand_ecclayout doc200x_oobinfo = {
1062 .useecc = MTD_NANDECC_AUTOPLACE,
1063 .eccbytes = 6, 1062 .eccbytes = 6,
1064 .eccpos = {0, 1, 2, 3, 4, 5}, 1063 .eccpos = {0, 1, 2, 3, 4, 5},
1065 .oobfree = {{8, 8}, {6, 2}} 1064 .oobfree = {{8, 8}, {6, 2}}
@@ -1662,7 +1661,7 @@ static int __init doc_probe(unsigned long physadr)
1662 nand->ecc.calculate = doc200x_calculate_ecc; 1661 nand->ecc.calculate = doc200x_calculate_ecc;
1663 nand->ecc.correct = doc200x_correct_data; 1662 nand->ecc.correct = doc200x_correct_data;
1664 1663
1665 nand->autooob = &doc200x_oobinfo; 1664 nand->ecc.layout = &doc200x_oobinfo;
1666 nand->ecc.mode = NAND_ECC_HW_SYNDROME; 1665 nand->ecc.mode = NAND_ECC_HW_SYNDROME;
1667 nand->ecc.size = 512; 1666 nand->ecc.size = 512;
1668 nand->ecc.bytes = 6; 1667 nand->ecc.bytes = 6;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 20f79fec73b5..e922b829c4be 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -52,28 +52,33 @@
52#endif 52#endif
53 53
54/* Define default oob placement schemes for large and small page devices */ 54/* Define default oob placement schemes for large and small page devices */
55static struct nand_oobinfo nand_oob_8 = { 55static struct nand_ecclayout nand_oob_8 = {
56 .useecc = MTD_NANDECC_AUTOPLACE,
57 .eccbytes = 3, 56 .eccbytes = 3,
58 .eccpos = {0, 1, 2}, 57 .eccpos = {0, 1, 2},
59 .oobfree = {{3, 2}, {6, 2}} 58 .oobfree = {
59 {.offset = 3,
60 .length = 2},
61 {.offset = 6,
62 .length = 2}}
60}; 63};
61 64
62static struct nand_oobinfo nand_oob_16 = { 65static struct nand_ecclayout nand_oob_16 = {
63 .useecc = MTD_NANDECC_AUTOPLACE,
64 .eccbytes = 6, 66 .eccbytes = 6,
65 .eccpos = {0, 1, 2, 3, 6, 7}, 67 .eccpos = {0, 1, 2, 3, 6, 7},
66 .oobfree = {{8, 8}} 68 .oobfree = {
69 {.offset = 8,
70 . length = 8}}
67}; 71};
68 72
69static struct nand_oobinfo nand_oob_64 = { 73static struct nand_ecclayout nand_oob_64 = {
70 .useecc = MTD_NANDECC_AUTOPLACE,
71 .eccbytes = 24, 74 .eccbytes = 24,
72 .eccpos = { 75 .eccpos = {
73 40, 41, 42, 43, 44, 45, 46, 47, 76 40, 41, 42, 43, 44, 45, 46, 47,
74 48, 49, 50, 51, 52, 53, 54, 55, 77 48, 49, 50, 51, 52, 53, 54, 55,
75 56, 57, 58, 59, 60, 61, 62, 63}, 78 56, 57, 58, 59, 60, 61, 62, 63},
76 .oobfree = {{2, 38}} 79 .oobfree = {
80 {.offset = 2,
81 .length = 38}}
77}; 82};
78 83
79/* This is used for padding purposes in nand_write_oob */ 84/* This is used for padding purposes in nand_write_oob */
@@ -749,7 +754,7 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
749 uint8_t *p = buf; 754 uint8_t *p = buf;
750 uint8_t *ecc_calc = chip->buffers.ecccalc; 755 uint8_t *ecc_calc = chip->buffers.ecccalc;
751 uint8_t *ecc_code = chip->buffers.ecccode; 756 uint8_t *ecc_code = chip->buffers.ecccode;
752 int *eccpos = chip->autooob->eccpos; 757 int *eccpos = chip->ecc.layout->eccpos;
753 758
754 chip->read_buf(mtd, buf, mtd->writesize); 759 chip->read_buf(mtd, buf, mtd->writesize);
755 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); 760 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
@@ -795,7 +800,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
795 uint8_t *p = buf; 800 uint8_t *p = buf;
796 uint8_t *ecc_calc = chip->buffers.ecccalc; 801 uint8_t *ecc_calc = chip->buffers.ecccalc;
797 uint8_t *ecc_code = chip->buffers.ecccode; 802 uint8_t *ecc_code = chip->buffers.ecccode;
798 int *eccpos = chip->autooob->eccpos; 803 int *eccpos = chip->ecc.layout->eccpos;
799 804
800 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { 805 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
801 chip->ecc.hwctl(mtd, NAND_ECC_READ); 806 chip->ecc.hwctl(mtd, NAND_ECC_READ);
@@ -1198,7 +1203,7 @@ static void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
1198 int eccsteps = chip->ecc.steps; 1203 int eccsteps = chip->ecc.steps;
1199 uint8_t *ecc_calc = chip->buffers.ecccalc; 1204 uint8_t *ecc_calc = chip->buffers.ecccalc;
1200 const uint8_t *p = buf; 1205 const uint8_t *p = buf;
1201 int *eccpos = chip->autooob->eccpos; 1206 int *eccpos = chip->ecc.layout->eccpos;
1202 1207
1203 if (chip->ecc.mode != NAND_ECC_NONE) { 1208 if (chip->ecc.mode != NAND_ECC_NONE) {
1204 /* Software ecc calculation */ 1209 /* Software ecc calculation */
@@ -1227,7 +1232,7 @@ static void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
1227 int eccsteps = chip->ecc.steps; 1232 int eccsteps = chip->ecc.steps;
1228 uint8_t *ecc_calc = chip->buffers.ecccalc; 1233 uint8_t *ecc_calc = chip->buffers.ecccalc;
1229 const uint8_t *p = buf; 1234 const uint8_t *p = buf;
1230 int *eccpos = chip->autooob->eccpos; 1235 int *eccpos = chip->ecc.layout->eccpos;
1231 1236
1232 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { 1237 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
1233 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); 1238 chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
@@ -2124,16 +2129,16 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2124 /* 2129 /*
2125 * If no default placement scheme is given, select an appropriate one 2130 * If no default placement scheme is given, select an appropriate one
2126 */ 2131 */
2127 if (!chip->autooob) { 2132 if (!chip->ecc.layout) {
2128 switch (mtd->oobsize) { 2133 switch (mtd->oobsize) {
2129 case 8: 2134 case 8:
2130 chip->autooob = &nand_oob_8; 2135 chip->ecc.layout = &nand_oob_8;
2131 break; 2136 break;
2132 case 16: 2137 case 16:
2133 chip->autooob = &nand_oob_16; 2138 chip->ecc.layout = &nand_oob_16;
2134 break; 2139 break;
2135 case 64: 2140 case 64:
2136 chip->autooob = &nand_oob_64; 2141 chip->ecc.layout = &nand_oob_64;
2137 break; 2142 break;
2138 default: 2143 default:
2139 printk(KERN_WARNING "No oob scheme defined for " 2144 printk(KERN_WARNING "No oob scheme defined for "
@@ -2198,6 +2203,15 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2198 } 2203 }
2199 2204
2200 /* 2205 /*
2206 * The number of bytes available for a client to place data into
2207 * the out of band area
2208 */
2209 chip->ecc.layout->oobavail = 0;
2210 for (i = 0; chip->ecc.layout->oobfree[i].length; i++)
2211 chip->ecc.layout->oobavail +=
2212 chip->ecc.layout->oobfree[i].length;
2213
2214 /*
2201 * Set the number of read / write steps for one page depending on ECC 2215 * Set the number of read / write steps for one page depending on ECC
2202 * mode 2216 * mode
2203 */ 2217 */
@@ -2236,8 +2250,8 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2236 mtd->block_isbad = nand_block_isbad; 2250 mtd->block_isbad = nand_block_isbad;
2237 mtd->block_markbad = nand_block_markbad; 2251 mtd->block_markbad = nand_block_markbad;
2238 2252
2239 /* and make the autooob the default one */ 2253 /* propagate ecc.layout to mtd_info */
2240 mtd->oobinfo = chip->autooob; 2254 mtd->ecclayout = chip->ecc.layout;
2241 2255
2242 /* Check, if we should skip the bad block table scan */ 2256 /* Check, if we should skip the bad block table scan */
2243 if (chip->options & NAND_SKIP_BBTSCAN) 2257 if (chip->options & NAND_SKIP_BBTSCAN)
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 5790d630faed..551702ddcacb 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -168,7 +168,7 @@ static void ndfc_chip_init(struct ndfc_nand_mtd *mtd)
168 chip->ecc.mode = NAND_ECC_HW; 168 chip->ecc.mode = NAND_ECC_HW;
169 chip->ecc.size = 256; 169 chip->ecc.size = 256;
170 chip->ecc.bytes = 3; 170 chip->ecc.bytes = 3;
171 chip->autooob = mtd->pl_chip->oobinfo; 171 chip->ecclayout = mtd->pl_chip->ecclayout;
172 mtd->mtd.priv = chip; 172 mtd->mtd.priv = chip;
173 mtd->mtd.owner = THIS_MODULE; 173 mtd->mtd.owner = THIS_MODULE;
174} 174}
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
index de6de91fbad9..f8c49645324d 100644
--- a/drivers/mtd/nand/rtc_from4.c
+++ b/drivers/mtd/nand/rtc_from4.c
@@ -142,8 +142,7 @@ static struct rs_control *rs_decoder;
142/* 142/*
143 * hardware specific Out Of Band information 143 * hardware specific Out Of Band information
144 */ 144 */
145static struct nand_oobinfo rtc_from4_nand_oobinfo = { 145static struct nand_ecclayout rtc_from4_nand_oobinfo = {
146 .useecc = MTD_NANDECC_AUTOPLACE,
147 .eccbytes = 32, 146 .eccbytes = 32,
148 .eccpos = { 147 .eccpos = {
149 0, 1, 2, 3, 4, 5, 6, 7, 148 0, 1, 2, 3, 4, 5, 6, 7,
@@ -574,7 +573,7 @@ static int __init rtc_from4_init(void)
574 /* return the status of extra status and ECC checks */ 573 /* return the status of extra status and ECC checks */
575 this->errstat = rtc_from4_errstat; 574 this->errstat = rtc_from4_errstat;
576 /* set the nand_oobinfo to support FPGA H/W error detection */ 575 /* set the nand_oobinfo to support FPGA H/W error detection */
577 this->autooob = &rtc_from4_nand_oobinfo; 576 this->ecc.layout = &rtc_from4_nand_oobinfo;
578 this->ecc.hwctl = rtc_from4_enable_hwecc; 577 this->ecc.hwctl = rtc_from4_enable_hwecc;
579 this->ecc.calculate = rtc_from4_calculate_ecc; 578 this->ecc.calculate = rtc_from4_calculate_ecc;
580 this->ecc.correct = rtc_from4_correct_data; 579 this->ecc.correct = rtc_from4_correct_data;
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 215227d1a65c..8429793a6288 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -76,8 +76,7 @@ static int hardware_ecc = 0;
76/* new oob placement block for use with hardware ecc generation 76/* new oob placement block for use with hardware ecc generation
77 */ 77 */
78 78
79static struct nand_oobinfo nand_hw_eccoob = { 79static struct nand_ecclayout nand_hw_eccoob = {
80 .useecc = MTD_NANDECC_AUTOPLACE,
81 .eccbytes = 3, 80 .eccbytes = 3,
82 .eccpos = {0, 1, 2}, 81 .eccpos = {0, 1, 2},
83 .oobfree = {{8, 8}} 82 .oobfree = {{8, 8}}
@@ -502,7 +501,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
502 chip->ecc.mode = NAND_ECC_HW; 501 chip->ecc.mode = NAND_ECC_HW;
503 chip->ecc.size = 512; 502 chip->ecc.size = 512;
504 chip->ecc.bytes = 3; 503 chip->ecc.bytes = 3;
505 chip->autooob = &nand_hw_eccoob; 504 chip->ecc.layout = &nand_hw_eccoob;
506 505
507 if (info->is_s3c2440) { 506 if (info->is_s3c2440) {
508 chip->ecc.hwctl = s3c2440_nand_enable_hwecc; 507 chip->ecc.hwctl = s3c2440_nand_enable_hwecc;
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index 45a1da724bff..21743658d150 100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -115,8 +115,7 @@ static struct nand_bbt_descr sharpsl_akita_bbt = {
115 .pattern = scan_ff_pattern 115 .pattern = scan_ff_pattern
116}; 116};
117 117
118static struct nand_oobinfo akita_oobinfo = { 118static struct nand_ecclayout akita_oobinfo = {
119 .useecc = MTD_NANDECC_AUTOPLACE,
120 .eccbytes = 24, 119 .eccbytes = 24,
121 .eccpos = { 120 .eccpos = {
122 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11, 121 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
@@ -202,7 +201,7 @@ static int __init sharpsl_nand_init(void)
202 this->badblock_pattern = &sharpsl_bbt; 201 this->badblock_pattern = &sharpsl_bbt;
203 if (machine_is_akita() || machine_is_borzoi()) { 202 if (machine_is_akita() || machine_is_borzoi()) {
204 this->badblock_pattern = &sharpsl_akita_bbt; 203 this->badblock_pattern = &sharpsl_akita_bbt;
205 this->autooob = &akita_oobinfo; 204 this->ecc.layout = &akita_oobinfo;
206 } 205 }
207 this->ecc.hwctl = sharpsl_nand_enable_hwecc; 206 this->ecc.hwctl = sharpsl_nand_enable_hwecc;
208 this->ecc.calculate = sharpsl_nand_calculate_ecc; 207 this->ecc.calculate = sharpsl_nand_calculate_ecc;