aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c4
-rw-r--r--drivers/mtd/devices/doc2000.c2
-rw-r--r--drivers/mtd/devices/doc2001.c2
-rw-r--r--drivers/mtd/devices/doc2001plus.c2
-rw-r--r--drivers/mtd/mtdconcat.c10
-rw-r--r--drivers/mtd/mtdpart.c2
-rw-r--r--drivers/mtd/nand/au1550nd.c4
-rw-r--r--drivers/mtd/nand/diskonchip.c16
-rw-r--r--drivers/mtd/nand/nand_base.c64
-rw-r--r--drivers/mtd/nand/nand_bbt.c30
-rw-r--r--drivers/mtd/nand/nandsim.c2
-rw-r--r--drivers/mtd/nand/rtc_from4.c2
-rw-r--r--drivers/mtd/onenand/onenand_base.c72
-rw-r--r--drivers/mtd/onenand/onenand_bbt.c4
-rw-r--r--fs/jffs2/wbuf.c6
-rw-r--r--include/linux/mtd/mtd.h7
-rw-r--r--include/mtd/mtd-abi.h2
17 files changed, 117 insertions, 114 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index d0d5e521b564..35c3689bc5c1 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -545,12 +545,12 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
545 if (extp->MinorVersion >= '4') { 545 if (extp->MinorVersion >= '4') {
546 struct cfi_intelext_programming_regioninfo *prinfo; 546 struct cfi_intelext_programming_regioninfo *prinfo;
547 prinfo = (struct cfi_intelext_programming_regioninfo *)&extp->extra[offs]; 547 prinfo = (struct cfi_intelext_programming_regioninfo *)&extp->extra[offs];
548 MTD_PROGREGION_SIZE(mtd) = cfi->interleave << prinfo->ProgRegShift; 548 mtd->writesize = cfi->interleave << prinfo->ProgRegShift;
549 MTD_PROGREGION_CTRLMODE_VALID(mtd) = cfi->interleave * prinfo->ControlValid; 549 MTD_PROGREGION_CTRLMODE_VALID(mtd) = cfi->interleave * prinfo->ControlValid;
550 MTD_PROGREGION_CTRLMODE_INVALID(mtd) = cfi->interleave * prinfo->ControlInvalid; 550 MTD_PROGREGION_CTRLMODE_INVALID(mtd) = cfi->interleave * prinfo->ControlInvalid;
551 mtd->flags |= MTD_PROGRAM_REGIONS; 551 mtd->flags |= MTD_PROGRAM_REGIONS;
552 printk(KERN_DEBUG "%s: program region size/ctrl_valid/ctrl_inval = %d/%d/%d\n", 552 printk(KERN_DEBUG "%s: program region size/ctrl_valid/ctrl_inval = %d/%d/%d\n",
553 map->name, MTD_PROGREGION_SIZE(mtd), 553 map->name, mtd->writesize,
554 MTD_PROGREGION_CTRLMODE_VALID(mtd), 554 MTD_PROGREGION_CTRLMODE_VALID(mtd),
555 MTD_PROGREGION_CTRLMODE_INVALID(mtd)); 555 MTD_PROGREGION_CTRLMODE_INVALID(mtd));
556 } 556 }
diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
index 40cc20f6d164..423a34f4638c 100644
--- a/drivers/mtd/devices/doc2000.c
+++ b/drivers/mtd/devices/doc2000.c
@@ -579,7 +579,7 @@ void DoC2k_init(struct mtd_info *mtd)
579 mtd->ecctype = MTD_ECC_RS_DiskOnChip; 579 mtd->ecctype = MTD_ECC_RS_DiskOnChip;
580 mtd->size = 0; 580 mtd->size = 0;
581 mtd->erasesize = 0; 581 mtd->erasesize = 0;
582 mtd->oobblock = 512; 582 mtd->writesize = 512;
583 mtd->oobsize = 16; 583 mtd->oobsize = 16;
584 mtd->owner = THIS_MODULE; 584 mtd->owner = THIS_MODULE;
585 mtd->erase = doc_erase; 585 mtd->erase = doc_erase;
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
index 1670eb8b9755..e6eaef28a2b0 100644
--- a/drivers/mtd/devices/doc2001.c
+++ b/drivers/mtd/devices/doc2001.c
@@ -361,7 +361,7 @@ void DoCMil_init(struct mtd_info *mtd)
361 /* FIXME: erase size is not always 8KiB */ 361 /* FIXME: erase size is not always 8KiB */
362 mtd->erasesize = 0x2000; 362 mtd->erasesize = 0x2000;
363 363
364 mtd->oobblock = 512; 364 mtd->writesize = 512;
365 mtd->oobsize = 16; 365 mtd->oobsize = 16;
366 mtd->owner = THIS_MODULE; 366 mtd->owner = THIS_MODULE;
367 mtd->erase = doc_erase; 367 mtd->erase = doc_erase;
diff --git a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c
index 0dc5d108f7b5..8422c5e92d27 100644
--- a/drivers/mtd/devices/doc2001plus.c
+++ b/drivers/mtd/devices/doc2001plus.c
@@ -483,7 +483,7 @@ void DoCMilPlus_init(struct mtd_info *mtd)
483 mtd->size = 0; 483 mtd->size = 0;
484 484
485 mtd->erasesize = 0; 485 mtd->erasesize = 0;
486 mtd->oobblock = 512; 486 mtd->writesize = 512;
487 mtd->oobsize = 16; 487 mtd->oobsize = 16;
488 mtd->owner = THIS_MODULE; 488 mtd->owner = THIS_MODULE;
489 mtd->erase = doc_erase; 489 mtd->erase = doc_erase;
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 3c61a980c56c..a5e8373349a5 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -278,9 +278,9 @@ concat_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
278 return -EINVAL; 278 return -EINVAL;
279 279
280 /* Check alignment */ 280 /* Check alignment */
281 if (mtd->oobblock > 1) { 281 if (mtd->writesize > 1) {
282 loff_t __to = to; 282 loff_t __to = to;
283 if (do_div(__to, mtd->oobblock) || (total_len % mtd->oobblock)) 283 if (do_div(__to, mtd->writesize) || (total_len % mtd->writesize))
284 return -EINVAL; 284 return -EINVAL;
285 } 285 }
286 286
@@ -334,7 +334,7 @@ concat_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
334 *retlen += retsize; 334 *retlen += retsize;
335 total_len -= wsize; 335 total_len -= wsize;
336 if (concat->mtd.type == MTD_NANDFLASH && eccbuf) 336 if (concat->mtd.type == MTD_NANDFLASH && eccbuf)
337 eccbuf += mtd->oobavail * (wsize / mtd->oobblock); 337 eccbuf += mtd->oobavail * (wsize / mtd->writesize);
338 338
339 if (total_len == 0) 339 if (total_len == 0)
340 break; 340 break;
@@ -833,7 +833,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
833 concat->mtd.flags = subdev[0]->flags; 833 concat->mtd.flags = subdev[0]->flags;
834 concat->mtd.size = subdev[0]->size; 834 concat->mtd.size = subdev[0]->size;
835 concat->mtd.erasesize = subdev[0]->erasesize; 835 concat->mtd.erasesize = subdev[0]->erasesize;
836 concat->mtd.oobblock = subdev[0]->oobblock; 836 concat->mtd.writesize = subdev[0]->writesize;
837 concat->mtd.oobsize = subdev[0]->oobsize; 837 concat->mtd.oobsize = subdev[0]->oobsize;
838 concat->mtd.ecctype = subdev[0]->ecctype; 838 concat->mtd.ecctype = subdev[0]->ecctype;
839 concat->mtd.eccsize = subdev[0]->eccsize; 839 concat->mtd.eccsize = subdev[0]->eccsize;
@@ -881,7 +881,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
881 subdev[i]->flags & MTD_WRITEABLE; 881 subdev[i]->flags & MTD_WRITEABLE;
882 } 882 }
883 concat->mtd.size += subdev[i]->size; 883 concat->mtd.size += subdev[i]->size;
884 if (concat->mtd.oobblock != subdev[i]->oobblock || 884 if (concat->mtd.writesize != subdev[i]->writesize ||
885 concat->mtd.oobsize != subdev[i]->oobsize || 885 concat->mtd.oobsize != subdev[i]->oobsize ||
886 concat->mtd.ecctype != subdev[i]->ecctype || 886 concat->mtd.ecctype != subdev[i]->ecctype ||
887 concat->mtd.eccsize != subdev[i]->eccsize || 887 concat->mtd.eccsize != subdev[i]->eccsize ||
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 29ed5abe70c4..082662f90481 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -398,7 +398,7 @@ int add_mtd_partitions(struct mtd_info *master,
398 slave->mtd.type = master->type; 398 slave->mtd.type = master->type;
399 slave->mtd.flags = master->flags & ~parts[i].mask_flags; 399 slave->mtd.flags = master->flags & ~parts[i].mask_flags;
400 slave->mtd.size = parts[i].size; 400 slave->mtd.size = parts[i].size;
401 slave->mtd.oobblock = master->oobblock; 401 slave->mtd.writesize = master->writesize;
402 slave->mtd.oobsize = master->oobsize; 402 slave->mtd.oobsize = master->oobsize;
403 slave->mtd.oobavail = master->oobavail; 403 slave->mtd.oobavail = master->oobavail;
404 slave->mtd.ecctype = master->ecctype; 404 slave->mtd.ecctype = master->ecctype;
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
index d9a0143e1d3a..4253b9309789 100644
--- a/drivers/mtd/nand/au1550nd.c
+++ b/drivers/mtd/nand/au1550nd.c
@@ -356,9 +356,9 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i
356 if (command == NAND_CMD_SEQIN) { 356 if (command == NAND_CMD_SEQIN) {
357 int readcmd; 357 int readcmd;
358 358
359 if (column >= mtd->oobblock) { 359 if (column >= mtd->writesize) {
360 /* OOB area */ 360 /* OOB area */
361 column -= mtd->oobblock; 361 column -= mtd->writesize;
362 readcmd = NAND_CMD_READOOB; 362 readcmd = NAND_CMD_READOOB;
363 } else if (column < 256) { 363 } else if (column < 256) {
364 /* First 256 bytes --> READ0 */ 364 /* First 256 bytes --> READ0 */
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index a2391c66a63f..d160930276d6 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -761,9 +761,9 @@ static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int colu
761 if (command == NAND_CMD_SEQIN) { 761 if (command == NAND_CMD_SEQIN) {
762 int readcmd; 762 int readcmd;
763 763
764 if (column >= mtd->oobblock) { 764 if (column >= mtd->writesize) {
765 /* OOB area */ 765 /* OOB area */
766 column -= mtd->oobblock; 766 column -= mtd->writesize;
767 readcmd = NAND_CMD_READOOB; 767 readcmd = NAND_CMD_READOOB;
768 } else if (column < 256) { 768 } else if (column < 256) {
769 /* First 256 bytes --> READ0 */ 769 /* First 256 bytes --> READ0 */
@@ -1093,8 +1093,8 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch
1093 size_t retlen; 1093 size_t retlen;
1094 1094
1095 for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { 1095 for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
1096 ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); 1096 ret = mtd->read(mtd, offs, mtd->writesize, &retlen, buf);
1097 if (retlen != mtd->oobblock) 1097 if (retlen != mtd->writesize)
1098 continue; 1098 continue;
1099 if (ret) { 1099 if (ret) {
1100 printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", offs); 1100 printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", offs);
@@ -1118,8 +1118,8 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch
1118 /* Only one mediaheader was found. We want buf to contain a 1118 /* Only one mediaheader was found. We want buf to contain a
1119 mediaheader on return, so we'll have to re-read the one we found. */ 1119 mediaheader on return, so we'll have to re-read the one we found. */
1120 offs = doc->mh0_page << this->page_shift; 1120 offs = doc->mh0_page << this->page_shift;
1121 ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); 1121 ret = mtd->read(mtd, offs, mtd->writesize, &retlen, buf);
1122 if (retlen != mtd->oobblock) { 1122 if (retlen != mtd->writesize) {
1123 /* Insanity. Give up. */ 1123 /* Insanity. Give up. */
1124 printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n"); 1124 printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n");
1125 return 0; 1125 return 0;
@@ -1139,7 +1139,7 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partitio
1139 unsigned blocks, maxblocks; 1139 unsigned blocks, maxblocks;
1140 int offs, numheaders; 1140 int offs, numheaders;
1141 1141
1142 buf = kmalloc(mtd->oobblock, GFP_KERNEL); 1142 buf = kmalloc(mtd->writesize, GFP_KERNEL);
1143 if (!buf) { 1143 if (!buf) {
1144 printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); 1144 printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n");
1145 return 0; 1145 return 0;
@@ -1247,7 +1247,7 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partiti
1247 if (inftl_bbt_write) 1247 if (inftl_bbt_write)
1248 end -= (INFTL_BBT_RESERVED_BLOCKS << this->phys_erase_shift); 1248 end -= (INFTL_BBT_RESERVED_BLOCKS << this->phys_erase_shift);
1249 1249
1250 buf = kmalloc(mtd->oobblock, GFP_KERNEL); 1250 buf = kmalloc(mtd->writesize, GFP_KERNEL);
1251 if (!buf) { 1251 if (!buf) {
1252 printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); 1252 printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n");
1253 return 0; 1253 return 0;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 08dffb7a9389..055f6608a2ec 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -560,9 +560,9 @@ static void nand_command(struct mtd_info *mtd, unsigned command, int column, int
560 if (command == NAND_CMD_SEQIN) { 560 if (command == NAND_CMD_SEQIN) {
561 int readcmd; 561 int readcmd;
562 562
563 if (column >= mtd->oobblock) { 563 if (column >= mtd->writesize) {
564 /* OOB area */ 564 /* OOB area */
565 column -= mtd->oobblock; 565 column -= mtd->writesize;
566 readcmd = NAND_CMD_READOOB; 566 readcmd = NAND_CMD_READOOB;
567 } else if (column < 256) { 567 } else if (column < 256) {
568 /* First 256 bytes --> READ0 */ 568 /* First 256 bytes --> READ0 */
@@ -658,7 +658,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column,
658 658
659 /* Emulate NAND_CMD_READOOB */ 659 /* Emulate NAND_CMD_READOOB */
660 if (command == NAND_CMD_READOOB) { 660 if (command == NAND_CMD_READOOB) {
661 column += mtd->oobblock; 661 column += mtd->writesize;
662 command = NAND_CMD_READ0; 662 command = NAND_CMD_READ0;
663 } 663 }
664 664
@@ -889,7 +889,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
889 /* No ecc, write all */ 889 /* No ecc, write all */
890 case NAND_ECC_NONE: 890 case NAND_ECC_NONE:
891 printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); 891 printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n");
892 this->write_buf(mtd, this->data_poi, mtd->oobblock); 892 this->write_buf(mtd, this->data_poi, mtd->writesize);
893 break; 893 break;
894 894
895 /* Software ecc 3/256, write all */ 895 /* Software ecc 3/256, write all */
@@ -900,7 +900,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
900 oob_buf[oob_config[eccidx]] = ecc_code[i]; 900 oob_buf[oob_config[eccidx]] = ecc_code[i];
901 datidx += this->eccsize; 901 datidx += this->eccsize;
902 } 902 }
903 this->write_buf(mtd, this->data_poi, mtd->oobblock); 903 this->write_buf(mtd, this->data_poi, mtd->writesize);
904 break; 904 break;
905 default: 905 default:
906 eccbytes = this->eccbytes; 906 eccbytes = this->eccbytes;
@@ -1161,9 +1161,9 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
1161 page = realpage & this->pagemask; 1161 page = realpage & this->pagemask;
1162 1162
1163 /* Get raw starting column */ 1163 /* Get raw starting column */
1164 col = from & (mtd->oobblock - 1); 1164 col = from & (mtd->writesize - 1);
1165 1165
1166 end = mtd->oobblock; 1166 end = mtd->writesize;
1167 ecc = this->eccsize; 1167 ecc = this->eccsize;
1168 eccbytes = this->eccbytes; 1168 eccbytes = this->eccbytes;
1169 1169
@@ -1321,7 +1321,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
1321 buf[read++] = data_poi[j]; 1321 buf[read++] = data_poi[j];
1322 this->pagebuf = realpage; 1322 this->pagebuf = realpage;
1323 } else 1323 } else
1324 read += mtd->oobblock; 1324 read += mtd->writesize;
1325 1325
1326 /* Apply delay or wait for ready/busy pin 1326 /* Apply delay or wait for ready/busy pin
1327 * Do this before the AUTOINCR check, so no problems 1327 * Do this before the AUTOINCR check, so no problems
@@ -1479,7 +1479,7 @@ int nand_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, s
1479 int chip = (int)(from >> this->chip_shift); 1479 int chip = (int)(from >> this->chip_shift);
1480 int sndcmd = 1; 1480 int sndcmd = 1;
1481 int cnt = 0; 1481 int cnt = 0;
1482 int pagesize = mtd->oobblock + mtd->oobsize; 1482 int pagesize = mtd->writesize + mtd->oobsize;
1483 int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; 1483 int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1;
1484 1484
1485 /* Do not allow reads past end of device */ 1485 /* Do not allow reads past end of device */
@@ -1581,7 +1581,7 @@ static u_char *nand_prepare_oobbuf(struct mtd_info *mtd, u_char *fsbuf, struct n
1581 return this->oob_buf; 1581 return this->oob_buf;
1582} 1582}
1583 1583
1584#define NOTALIGNED(x) (x & (mtd->oobblock-1)) != 0 1584#define NOTALIGNED(x) (x & (mtd->writesize-1)) != 0
1585 1585
1586/** 1586/**
1587 * nand_write - [MTD Interface] compability function for nand_write_ecc 1587 * nand_write - [MTD Interface] compability function for nand_write_ecc
@@ -1694,7 +1694,7 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
1694 /* Next oob page */ 1694 /* Next oob page */
1695 oob += mtd->oobsize; 1695 oob += mtd->oobsize;
1696 /* Update written bytes count */ 1696 /* Update written bytes count */
1697 written += mtd->oobblock; 1697 written += mtd->writesize;
1698 if (written == len) 1698 if (written == len)
1699 goto cmp; 1699 goto cmp;
1700 1700
@@ -1805,7 +1805,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r
1805 1805
1806 if (NAND_MUST_PAD(this)) { 1806 if (NAND_MUST_PAD(this)) {
1807 /* Write out desired data */ 1807 /* Write out desired data */
1808 this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask); 1808 this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page & this->pagemask);
1809 /* prepad 0xff for partial programming */ 1809 /* prepad 0xff for partial programming */
1810 this->write_buf(mtd, ffchars, column); 1810 this->write_buf(mtd, ffchars, column);
1811 /* write data */ 1811 /* write data */
@@ -1814,7 +1814,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r
1814 this->write_buf(mtd, ffchars, mtd->oobsize - (len + column)); 1814 this->write_buf(mtd, ffchars, mtd->oobsize - (len + column));
1815 } else { 1815 } else {
1816 /* Write out desired data */ 1816 /* Write out desired data */
1817 this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask); 1817 this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize + column, page & this->pagemask);
1818 /* write data */ 1818 /* write data */
1819 this->write_buf(mtd, buf, len); 1819 this->write_buf(mtd, buf, len);
1820 } 1820 }
@@ -1947,7 +1947,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
1947 /* If the given tuple is >= pagesize then 1947 /* If the given tuple is >= pagesize then
1948 * write it out from the iov 1948 * write it out from the iov
1949 */ 1949 */
1950 if ((vecs->iov_len - len) >= mtd->oobblock) { 1950 if ((vecs->iov_len - len) >= mtd->writesize) {
1951 /* Calc number of pages we can write 1951 /* Calc number of pages we can write
1952 * out of this iov in one go */ 1952 * out of this iov in one go */
1953 numpages = (vecs->iov_len - len) >> this->page_shift; 1953 numpages = (vecs->iov_len - len) >> this->page_shift;
@@ -1967,8 +1967,8 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
1967 &oobbuf[oob], oobsel, i != numpages); 1967 &oobbuf[oob], oobsel, i != numpages);
1968 if (ret) 1968 if (ret)
1969 goto out; 1969 goto out;
1970 this->data_poi += mtd->oobblock; 1970 this->data_poi += mtd->writesize;
1971 len += mtd->oobblock; 1971 len += mtd->writesize;
1972 oob += mtd->oobsize; 1972 oob += mtd->oobsize;
1973 page++; 1973 page++;
1974 } 1974 }
@@ -1983,7 +1983,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
1983 * tuple until we have a full page to write 1983 * tuple until we have a full page to write
1984 */ 1984 */
1985 int cnt = 0; 1985 int cnt = 0;
1986 while (cnt < mtd->oobblock) { 1986 while (cnt < mtd->writesize) {
1987 if (vecs->iov_base != NULL && vecs->iov_len) 1987 if (vecs->iov_base != NULL && vecs->iov_len)
1988 this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; 1988 this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++];
1989 /* Check, if we have to switch to the next tuple */ 1989 /* Check, if we have to switch to the next tuple */
@@ -2009,7 +2009,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
2009 if (ret) 2009 if (ret)
2010 goto out; 2010 goto out;
2011 2011
2012 written += mtd->oobblock * numpages; 2012 written += mtd->writesize * numpages;
2013 /* All done ? */ 2013 /* All done ? */
2014 if (!count) 2014 if (!count)
2015 break; 2015 break;
@@ -2411,10 +2411,10 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2411 /* The 4th id byte is the important one */ 2411 /* The 4th id byte is the important one */
2412 extid = this->read_byte(mtd); 2412 extid = this->read_byte(mtd);
2413 /* Calc pagesize */ 2413 /* Calc pagesize */
2414 mtd->oobblock = 1024 << (extid & 0x3); 2414 mtd->writesize = 1024 << (extid & 0x3);
2415 extid >>= 2; 2415 extid >>= 2;
2416 /* Calc oobsize */ 2416 /* Calc oobsize */
2417 mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9); 2417 mtd->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9);
2418 extid >>= 2; 2418 extid >>= 2;
2419 /* Calc blocksize. Blocksize is multiples of 64KiB */ 2419 /* Calc blocksize. Blocksize is multiples of 64KiB */
2420 mtd->erasesize = (64 * 1024) << (extid & 0x03); 2420 mtd->erasesize = (64 * 1024) << (extid & 0x03);
@@ -2426,8 +2426,8 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2426 /* Old devices have this data hardcoded in the 2426 /* Old devices have this data hardcoded in the
2427 * device id table */ 2427 * device id table */
2428 mtd->erasesize = nand_flash_ids[i].erasesize; 2428 mtd->erasesize = nand_flash_ids[i].erasesize;
2429 mtd->oobblock = nand_flash_ids[i].pagesize; 2429 mtd->writesize = nand_flash_ids[i].pagesize;
2430 mtd->oobsize = mtd->oobblock / 32; 2430 mtd->oobsize = mtd->writesize / 32;
2431 busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16; 2431 busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16;
2432 } 2432 }
2433 2433
@@ -2451,12 +2451,12 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2451 } 2451 }
2452 2452
2453 /* Calculate the address shift from the page size */ 2453 /* Calculate the address shift from the page size */
2454 this->page_shift = ffs(mtd->oobblock) - 1; 2454 this->page_shift = ffs(mtd->writesize) - 1;
2455 this->bbt_erase_shift = this->phys_erase_shift = ffs(mtd->erasesize) - 1; 2455 this->bbt_erase_shift = this->phys_erase_shift = ffs(mtd->erasesize) - 1;
2456 this->chip_shift = ffs(this->chipsize) - 1; 2456 this->chip_shift = ffs(this->chipsize) - 1;
2457 2457
2458 /* Set the bad block position */ 2458 /* Set the bad block position */
2459 this->badblockpos = mtd->oobblock > 512 ? NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; 2459 this->badblockpos = mtd->writesize > 512 ? NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS;
2460 2460
2461 /* Get chip options, preserve non chip based options */ 2461 /* Get chip options, preserve non chip based options */
2462 this->options &= ~NAND_CHIPOPTIONS_MSK; 2462 this->options &= ~NAND_CHIPOPTIONS_MSK;
@@ -2476,7 +2476,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2476 this->erase_cmd = single_erase_cmd; 2476 this->erase_cmd = single_erase_cmd;
2477 2477
2478 /* Do not replace user supplied command function ! */ 2478 /* Do not replace user supplied command function ! */
2479 if (mtd->oobblock > 512 && this->cmdfunc == nand_command) 2479 if (mtd->writesize > 512 && this->cmdfunc == nand_command)
2480 this->cmdfunc = nand_command_lp; 2480 this->cmdfunc = nand_command_lp;
2481 2481
2482 printk(KERN_INFO "NAND device: Manufacturer ID:" 2482 printk(KERN_INFO "NAND device: Manufacturer ID:"
@@ -2519,7 +2519,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2519 2519
2520 if (!this->data_buf) { 2520 if (!this->data_buf) {
2521 size_t len; 2521 size_t len;
2522 len = mtd->oobblock + mtd->oobsize; 2522 len = mtd->writesize + mtd->oobsize;
2523 this->data_buf = kmalloc(len, GFP_KERNEL); 2523 this->data_buf = kmalloc(len, GFP_KERNEL);
2524 if (!this->data_buf) { 2524 if (!this->data_buf) {
2525 if (this->options & NAND_OOBBUF_ALLOC) 2525 if (this->options & NAND_OOBBUF_ALLOC)
@@ -2575,9 +2575,9 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2575 2575
2576 switch (this->eccmode) { 2576 switch (this->eccmode) {
2577 case NAND_ECC_HW12_2048: 2577 case NAND_ECC_HW12_2048:
2578 if (mtd->oobblock < 2048) { 2578 if (mtd->writesize < 2048) {
2579 printk(KERN_WARNING "2048 byte HW ECC not possible on %d byte page size, fallback to SW ECC\n", 2579 printk(KERN_WARNING "2048 byte HW ECC not possible on %d byte page size, fallback to SW ECC\n",
2580 mtd->oobblock); 2580 mtd->writesize);
2581 this->eccmode = NAND_ECC_SOFT; 2581 this->eccmode = NAND_ECC_SOFT;
2582 this->calculate_ecc = nand_calculate_ecc; 2582 this->calculate_ecc = nand_calculate_ecc;
2583 this->correct_data = nand_correct_data; 2583 this->correct_data = nand_correct_data;
@@ -2588,7 +2588,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2588 case NAND_ECC_HW3_512: 2588 case NAND_ECC_HW3_512:
2589 case NAND_ECC_HW6_512: 2589 case NAND_ECC_HW6_512:
2590 case NAND_ECC_HW8_512: 2590 case NAND_ECC_HW8_512:
2591 if (mtd->oobblock == 256) { 2591 if (mtd->writesize == 256) {
2592 printk(KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); 2592 printk(KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n");
2593 this->eccmode = NAND_ECC_SOFT; 2593 this->eccmode = NAND_ECC_SOFT;
2594 this->calculate_ecc = nand_calculate_ecc; 2594 this->calculate_ecc = nand_calculate_ecc;
@@ -2638,16 +2638,16 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2638 /* Set the number of read / write steps for one page to ensure ECC generation */ 2638 /* Set the number of read / write steps for one page to ensure ECC generation */
2639 switch (this->eccmode) { 2639 switch (this->eccmode) {
2640 case NAND_ECC_HW12_2048: 2640 case NAND_ECC_HW12_2048:
2641 this->eccsteps = mtd->oobblock / 2048; 2641 this->eccsteps = mtd->writesize / 2048;
2642 break; 2642 break;
2643 case NAND_ECC_HW3_512: 2643 case NAND_ECC_HW3_512:
2644 case NAND_ECC_HW6_512: 2644 case NAND_ECC_HW6_512:
2645 case NAND_ECC_HW8_512: 2645 case NAND_ECC_HW8_512:
2646 this->eccsteps = mtd->oobblock / 512; 2646 this->eccsteps = mtd->writesize / 512;
2647 break; 2647 break;
2648 case NAND_ECC_HW3_256: 2648 case NAND_ECC_HW3_256:
2649 case NAND_ECC_SOFT: 2649 case NAND_ECC_SOFT:
2650 this->eccsteps = mtd->oobblock / 256; 2650 this->eccsteps = mtd->writesize / 256;
2651 break; 2651 break;
2652 2652
2653 case NAND_ECC_NONE: 2653 case NAND_ECC_NONE:
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 9adc6d62332a..fbccb2a25186 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -247,15 +247,15 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des
247 247
248 /* Read the primary version, if available */ 248 /* Read the primary version, if available */
249 if (td->options & NAND_BBT_VERSION) { 249 if (td->options & NAND_BBT_VERSION) {
250 nand_read_raw(mtd, buf, td->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); 250 nand_read_raw(mtd, buf, td->pages[0] << this->page_shift, mtd->writesize, mtd->oobsize);
251 td->version[0] = buf[mtd->oobblock + td->veroffs]; 251 td->version[0] = buf[mtd->writesize + td->veroffs];
252 printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]); 252 printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]);
253 } 253 }
254 254
255 /* Read the mirror version, if available */ 255 /* Read the mirror version, if available */
256 if (md && (md->options & NAND_BBT_VERSION)) { 256 if (md && (md->options & NAND_BBT_VERSION)) {
257 nand_read_raw(mtd, buf, md->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); 257 nand_read_raw(mtd, buf, md->pages[0] << this->page_shift, mtd->writesize, mtd->oobsize);
258 md->version[0] = buf[mtd->oobblock + md->veroffs]; 258 md->version[0] = buf[mtd->writesize + md->veroffs];
259 printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]); 259 printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]);
260 } 260 }
261 261
@@ -298,8 +298,8 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
298 readlen = bd->len; 298 readlen = bd->len;
299 } else { 299 } else {
300 /* Full page content should be read */ 300 /* Full page content should be read */
301 scanlen = mtd->oobblock + mtd->oobsize; 301 scanlen = mtd->writesize + mtd->oobsize;
302 readlen = len * mtd->oobblock; 302 readlen = len * mtd->writesize;
303 ooblen = len * mtd->oobsize; 303 ooblen = len * mtd->oobsize;
304 } 304 }
305 305
@@ -334,7 +334,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
334 334
335 /* Read the full oob until read_oob is fixed to 335 /* Read the full oob until read_oob is fixed to
336 * handle single byte reads for 16 bit buswidth */ 336 * handle single byte reads for 16 bit buswidth */
337 ret = mtd->read_oob(mtd, from + j * mtd->oobblock, mtd->oobsize, &retlen, buf); 337 ret = mtd->read_oob(mtd, from + j * mtd->writesize, mtd->oobsize, &retlen, buf);
338 if (ret) 338 if (ret)
339 return ret; 339 return ret;
340 340
@@ -345,7 +345,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
345 break; 345 break;
346 } 346 }
347 } else { 347 } else {
348 if (check_pattern(&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { 348 if (check_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {
349 this->bbt[i >> 3] |= 0x03 << (i & 0x6); 349 this->bbt[i >> 3] |= 0x03 << (i & 0x6);
350 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 350 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
351 i >> 1, (unsigned int)from); 351 i >> 1, (unsigned int)from);
@@ -381,7 +381,7 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
381 struct nand_chip *this = mtd->priv; 381 struct nand_chip *this = mtd->priv;
382 int i, chips; 382 int i, chips;
383 int bits, startblock, block, dir; 383 int bits, startblock, block, dir;
384 int scanlen = mtd->oobblock + mtd->oobsize; 384 int scanlen = mtd->writesize + mtd->oobsize;
385 int bbtblocks; 385 int bbtblocks;
386 386
387 /* Search direction top -> down ? */ 387 /* Search direction top -> down ? */
@@ -414,11 +414,11 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
414 for (block = 0; block < td->maxblocks; block++) { 414 for (block = 0; block < td->maxblocks; block++) {
415 int actblock = startblock + dir * block; 415 int actblock = startblock + dir * block;
416 /* Read first page */ 416 /* Read first page */
417 nand_read_raw(mtd, buf, actblock << this->bbt_erase_shift, mtd->oobblock, mtd->oobsize); 417 nand_read_raw(mtd, buf, actblock << this->bbt_erase_shift, mtd->writesize, mtd->oobsize);
418 if (!check_pattern(buf, scanlen, mtd->oobblock, td)) { 418 if (!check_pattern(buf, scanlen, mtd->writesize, td)) {
419 td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift); 419 td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift);
420 if (td->options & NAND_BBT_VERSION) { 420 if (td->options & NAND_BBT_VERSION) {
421 td->version[i] = buf[mtd->oobblock + td->veroffs]; 421 td->version[i] = buf[mtd->writesize + td->veroffs];
422 } 422 }
423 break; 423 break;
424 } 424 }
@@ -586,7 +586,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
586 /* Calc length */ 586 /* Calc length */
587 len = (size_t) (numblocks >> sft); 587 len = (size_t) (numblocks >> sft);
588 /* Make it page aligned ! */ 588 /* Make it page aligned ! */
589 len = (len + (mtd->oobblock - 1)) & ~(mtd->oobblock - 1); 589 len = (len + (mtd->writesize - 1)) & ~(mtd->writesize - 1);
590 /* Preset the buffer with 0xff */ 590 /* Preset the buffer with 0xff */
591 memset(buf, 0xff, len + (len >> this->page_shift) * mtd->oobsize); 591 memset(buf, 0xff, len + (len >> this->page_shift) * mtd->oobsize);
592 offs = 0; 592 offs = 0;
@@ -1063,13 +1063,13 @@ int nand_default_bbt(struct mtd_info *mtd)
1063 this->bbt_md = &bbt_mirror_descr; 1063 this->bbt_md = &bbt_mirror_descr;
1064 } 1064 }
1065 if (!this->badblock_pattern) { 1065 if (!this->badblock_pattern) {
1066 this->badblock_pattern = (mtd->oobblock > 512) ? &largepage_flashbased : &smallpage_flashbased; 1066 this->badblock_pattern = (mtd->writesize > 512) ? &largepage_flashbased : &smallpage_flashbased;
1067 } 1067 }
1068 } else { 1068 } else {
1069 this->bbt_td = NULL; 1069 this->bbt_td = NULL;
1070 this->bbt_md = NULL; 1070 this->bbt_md = NULL;
1071 if (!this->badblock_pattern) { 1071 if (!this->badblock_pattern) {
1072 this->badblock_pattern = (mtd->oobblock > 512) ? 1072 this->badblock_pattern = (mtd->writesize > 512) ?
1073 &largepage_memorybased : &smallpage_memorybased; 1073 &largepage_memorybased : &smallpage_memorybased;
1074 } 1074 }
1075 } 1075 }
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 6903f5b903c6..8674f1e9d3c6 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -369,7 +369,7 @@ init_nandsim(struct mtd_info *mtd)
369 /* Initialize the NAND flash parameters */ 369 /* Initialize the NAND flash parameters */
370 ns->busw = chip->options & NAND_BUSWIDTH_16 ? 16 : 8; 370 ns->busw = chip->options & NAND_BUSWIDTH_16 ? 16 : 8;
371 ns->geom.totsz = mtd->size; 371 ns->geom.totsz = mtd->size;
372 ns->geom.pgsz = mtd->oobblock; 372 ns->geom.pgsz = mtd->writesize;
373 ns->geom.oobsz = mtd->oobsize; 373 ns->geom.oobsz = mtd->oobsize;
374 ns->geom.secsz = mtd->erasesize; 374 ns->geom.secsz = mtd->erasesize;
375 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz; 375 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz;
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
index bc9d849fbd5d..64ccf4c9613f 100644
--- a/drivers/mtd/nand/rtc_from4.c
+++ b/drivers/mtd/nand/rtc_from4.c
@@ -487,7 +487,7 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int s
487 if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { 487 if (!(rtn & ERR_STAT_ECC_AVAILABLE)) {
488 er_stat |= 1 << 1; /* err_ecc_not_avail */ 488 er_stat |= 1 << 1; /* err_ecc_not_avail */
489 } else { 489 } else {
490 len = mtd->oobblock; 490 len = mtd->writesize;
491 buf = kmalloc(len, GFP_KERNEL); 491 buf = kmalloc(len, GFP_KERNEL);
492 if (!buf) { 492 if (!buf) {
493 printk(KERN_ERR "rtc_from4_errstat: Out of memory!\n"); 493 printk(KERN_ERR "rtc_from4_errstat: Out of memory!\n");
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index fe5b48997275..198bb8562d93 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -354,7 +354,7 @@ static inline int onenand_bufferram_offset(struct mtd_info *mtd, int area)
354 354
355 if (ONENAND_CURRENT_BUFFERRAM(this)) { 355 if (ONENAND_CURRENT_BUFFERRAM(this)) {
356 if (area == ONENAND_DATARAM) 356 if (area == ONENAND_DATARAM)
357 return mtd->oobblock; 357 return mtd->writesize;
358 if (area == ONENAND_SPARERAM) 358 if (area == ONENAND_SPARERAM)
359 return mtd->oobsize; 359 return mtd->oobsize;
360 } 360 }
@@ -632,14 +632,14 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
632 /* TODO handling oob */ 632 /* TODO handling oob */
633 633
634 while (read < len) { 634 while (read < len) {
635 thislen = min_t(int, mtd->oobblock, len - read); 635 thislen = min_t(int, mtd->writesize, len - read);
636 636
637 column = from & (mtd->oobblock - 1); 637 column = from & (mtd->writesize - 1);
638 if (column + thislen > mtd->oobblock) 638 if (column + thislen > mtd->writesize)
639 thislen = mtd->oobblock - column; 639 thislen = mtd->writesize - column;
640 640
641 if (!onenand_check_bufferram(mtd, from)) { 641 if (!onenand_check_bufferram(mtd, from)) {
642 this->command(mtd, ONENAND_CMD_READ, from, mtd->oobblock); 642 this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize);
643 643
644 ret = this->wait(mtd, FL_READING); 644 ret = this->wait(mtd, FL_READING);
645 /* First copy data and check return value for ECC handling */ 645 /* First copy data and check return value for ECC handling */
@@ -752,7 +752,7 @@ static int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
752 /* Read more? */ 752 /* Read more? */
753 if (read < len) { 753 if (read < len) {
754 /* Page size */ 754 /* Page size */
755 from += mtd->oobblock; 755 from += mtd->writesize;
756 column = 0; 756 column = 0;
757 } 757 }
758 } 758 }
@@ -809,7 +809,7 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
809 void __iomem *dataram0, *dataram1; 809 void __iomem *dataram0, *dataram1;
810 int ret = 0; 810 int ret = 0;
811 811
812 this->command(mtd, ONENAND_CMD_READ, addr, mtd->oobblock); 812 this->command(mtd, ONENAND_CMD_READ, addr, mtd->writesize);
813 813
814 ret = this->wait(mtd, FL_READING); 814 ret = this->wait(mtd, FL_READING);
815 if (ret) 815 if (ret)
@@ -819,9 +819,9 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
819 819
820 /* Check, if the two dataram areas are same */ 820 /* Check, if the two dataram areas are same */
821 dataram0 = this->base + ONENAND_DATARAM; 821 dataram0 = this->base + ONENAND_DATARAM;
822 dataram1 = dataram0 + mtd->oobblock; 822 dataram1 = dataram0 + mtd->writesize;
823 823
824 if (memcmp(dataram0, dataram1, mtd->oobblock)) 824 if (memcmp(dataram0, dataram1, mtd->writesize))
825 return -EBADMSG; 825 return -EBADMSG;
826 826
827 return 0; 827 return 0;
@@ -831,7 +831,7 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
831#define onenand_verify_oob(...) (0) 831#define onenand_verify_oob(...) (0)
832#endif 832#endif
833 833
834#define NOTALIGNED(x) ((x & (mtd->oobblock - 1)) != 0) 834#define NOTALIGNED(x) ((x & (mtd->writesize - 1)) != 0)
835 835
836/** 836/**
837 * onenand_write_ecc - [MTD Interface] OneNAND write with ECC 837 * onenand_write_ecc - [MTD Interface] OneNAND write with ECC
@@ -875,14 +875,14 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
875 875
876 /* Loop until all data write */ 876 /* Loop until all data write */
877 while (written < len) { 877 while (written < len) {
878 int thislen = min_t(int, mtd->oobblock, len - written); 878 int thislen = min_t(int, mtd->writesize, len - written);
879 879
880 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock); 880 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->writesize);
881 881
882 this->write_bufferram(mtd, ONENAND_DATARAM, buf, 0, thislen); 882 this->write_bufferram(mtd, ONENAND_DATARAM, buf, 0, thislen);
883 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); 883 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
884 884
885 this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock); 885 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
886 886
887 onenand_update_bufferram(mtd, to, 1); 887 onenand_update_bufferram(mtd, to, 1);
888 888
@@ -1070,10 +1070,10 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
1070 * If the given tuple is >= pagesize then 1070 * If the given tuple is >= pagesize then
1071 * write it out from the iov 1071 * write it out from the iov
1072 */ 1072 */
1073 if ((vecs->iov_len - len) >= mtd->oobblock) { 1073 if ((vecs->iov_len - len) >= mtd->writesize) {
1074 pbuf = vecs->iov_base + len; 1074 pbuf = vecs->iov_base + len;
1075 1075
1076 len += mtd->oobblock; 1076 len += mtd->writesize;
1077 1077
1078 /* Check, if we have to switch to the next tuple */ 1078 /* Check, if we have to switch to the next tuple */
1079 if (len >= (int) vecs->iov_len) { 1079 if (len >= (int) vecs->iov_len) {
@@ -1083,8 +1083,8 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
1083 } 1083 }
1084 } else { 1084 } else {
1085 int cnt = 0, thislen; 1085 int cnt = 0, thislen;
1086 while (cnt < mtd->oobblock) { 1086 while (cnt < mtd->writesize) {
1087 thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len); 1087 thislen = min_t(int, mtd->writesize - cnt, vecs->iov_len - len);
1088 memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen); 1088 memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen);
1089 cnt += thislen; 1089 cnt += thislen;
1090 len += thislen; 1090 len += thislen;
@@ -1098,12 +1098,12 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
1098 } 1098 }
1099 } 1099 }
1100 1100
1101 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock); 1101 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->writesize);
1102 1102
1103 this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->oobblock); 1103 this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->writesize);
1104 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); 1104 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
1105 1105
1106 this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock); 1106 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
1107 1107
1108 onenand_update_bufferram(mtd, to, 1); 1108 onenand_update_bufferram(mtd, to, 1);
1109 1109
@@ -1121,9 +1121,9 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
1121 goto out; 1121 goto out;
1122 } 1122 }
1123 1123
1124 written += mtd->oobblock; 1124 written += mtd->writesize;
1125 1125
1126 to += mtd->oobblock; 1126 to += mtd->writesize;
1127 } 1127 }
1128 1128
1129out: 1129out:
@@ -1467,11 +1467,11 @@ static int do_otp_write(struct mtd_info *mtd, loff_t from, size_t len,
1467 int ret; 1467 int ret;
1468 1468
1469 /* Force buffer page aligned */ 1469 /* Force buffer page aligned */
1470 if (len < mtd->oobblock) { 1470 if (len < mtd->writesize) {
1471 memcpy(this->page_buf, buf, len); 1471 memcpy(this->page_buf, buf, len);
1472 memset(this->page_buf + len, 0xff, mtd->oobblock - len); 1472 memset(this->page_buf + len, 0xff, mtd->writesize - len);
1473 pbuf = this->page_buf; 1473 pbuf = this->page_buf;
1474 len = mtd->oobblock; 1474 len = mtd->writesize;
1475 } 1475 }
1476 1476
1477 /* Enter OTP access mode */ 1477 /* Enter OTP access mode */
@@ -1546,12 +1546,12 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
1546 otp_pages = 10; 1546 otp_pages = 10;
1547 1547
1548 if (mode == MTD_OTP_FACTORY) { 1548 if (mode == MTD_OTP_FACTORY) {
1549 from += mtd->oobblock * otp_pages; 1549 from += mtd->writesize * otp_pages;
1550 otp_pages = 64 - otp_pages; 1550 otp_pages = 64 - otp_pages;
1551 } 1551 }
1552 1552
1553 /* Check User/Factory boundary */ 1553 /* Check User/Factory boundary */
1554 if (((mtd->oobblock * otp_pages) - (from + len)) < 0) 1554 if (((mtd->writesize * otp_pages) - (from + len)) < 0)
1555 return 0; 1555 return 0;
1556 1556
1557 while (len > 0 && otp_pages > 0) { 1557 while (len > 0 && otp_pages > 0) {
@@ -1564,10 +1564,10 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
1564 1564
1565 otpinfo = (struct otp_info *) buf; 1565 otpinfo = (struct otp_info *) buf;
1566 otpinfo->start = from; 1566 otpinfo->start = from;
1567 otpinfo->length = mtd->oobblock; 1567 otpinfo->length = mtd->writesize;
1568 otpinfo->locked = 0; 1568 otpinfo->locked = 0;
1569 1569
1570 from += mtd->oobblock; 1570 from += mtd->writesize;
1571 buf += sizeof(struct otp_info); 1571 buf += sizeof(struct otp_info);
1572 *retlen += sizeof(struct otp_info); 1572 *retlen += sizeof(struct otp_info);
1573 } else { 1573 } else {
@@ -1811,15 +1811,15 @@ static int onenand_probe(struct mtd_info *mtd)
1811 1811
1812 /* OneNAND page size & block size */ 1812 /* OneNAND page size & block size */
1813 /* The data buffer size is equal to page size */ 1813 /* The data buffer size is equal to page size */
1814 mtd->oobblock = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE); 1814 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
1815 mtd->oobsize = mtd->oobblock >> 5; 1815 mtd->oobsize = mtd->writesize >> 5;
1816 /* Pagers per block is always 64 in OneNAND */ 1816 /* Pagers per block is always 64 in OneNAND */
1817 mtd->erasesize = mtd->oobblock << 6; 1817 mtd->erasesize = mtd->writesize << 6;
1818 1818
1819 this->erase_shift = ffs(mtd->erasesize) - 1; 1819 this->erase_shift = ffs(mtd->erasesize) - 1;
1820 this->page_shift = ffs(mtd->oobblock) - 1; 1820 this->page_shift = ffs(mtd->writesize) - 1;
1821 this->ppb_shift = (this->erase_shift - this->page_shift); 1821 this->ppb_shift = (this->erase_shift - this->page_shift);
1822 this->page_mask = (mtd->erasesize / mtd->oobblock) - 1; 1822 this->page_mask = (mtd->erasesize / mtd->writesize) - 1;
1823 1823
1824 /* REVIST: Multichip handling */ 1824 /* REVIST: Multichip handling */
1825 1825
@@ -1909,7 +1909,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1909 /* Allocate buffers, if necessary */ 1909 /* Allocate buffers, if necessary */
1910 if (!this->page_buf) { 1910 if (!this->page_buf) {
1911 size_t len; 1911 size_t len;
1912 len = mtd->oobblock + mtd->oobsize; 1912 len = mtd->writesize + mtd->oobsize;
1913 this->page_buf = kmalloc(len, GFP_KERNEL); 1913 this->page_buf = kmalloc(len, GFP_KERNEL);
1914 if (!this->page_buf) { 1914 if (!this->page_buf) {
1915 printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n"); 1915 printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n");
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c
index 4510d3361eaa..aafd7c2f7802 100644
--- a/drivers/mtd/onenand/onenand_bbt.c
+++ b/drivers/mtd/onenand/onenand_bbt.c
@@ -87,13 +87,13 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
87 87
88 /* No need to read pages fully, 88 /* No need to read pages fully,
89 * just read required OOB bytes */ 89 * just read required OOB bytes */
90 ret = mtd->read_oob(mtd, from + j * mtd->oobblock + bd->offs, 90 ret = mtd->read_oob(mtd, from + j * mtd->writesize + bd->offs,
91 readlen, &retlen, &buf[0]); 91 readlen, &retlen, &buf[0]);
92 92
93 if (ret) 93 if (ret)
94 return ret; 94 return ret;
95 95
96 if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { 96 if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {
97 bbm->bbt[i >> 3] |= 0x03 << (i & 0x6); 97 bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);
98 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 98 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
99 i >> 1, (unsigned int) from); 99 i >> 1, (unsigned int) from);
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 62f685faeba8..355226d8ce29 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -1173,7 +1173,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
1173 1173
1174 /* Initialise write buffer */ 1174 /* Initialise write buffer */
1175 init_rwsem(&c->wbuf_sem); 1175 init_rwsem(&c->wbuf_sem);
1176 c->wbuf_pagesize = c->mtd->oobblock; 1176 c->wbuf_pagesize = c->mtd->writesize;
1177 c->wbuf_ofs = 0xFFFFFFFF; 1177 c->wbuf_ofs = 0xFFFFFFFF;
1178 1178
1179 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); 1179 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
@@ -1266,11 +1266,11 @@ void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) {
1266 1266
1267int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) { 1267int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) {
1268 /* Cleanmarker currently occupies a whole programming region */ 1268 /* Cleanmarker currently occupies a whole programming region */
1269 c->cleanmarker_size = MTD_PROGREGION_SIZE(c->mtd); 1269 c->cleanmarker_size = c->mtd->writesize;
1270 1270
1271 /* Initialize write buffer */ 1271 /* Initialize write buffer */
1272 init_rwsem(&c->wbuf_sem); 1272 init_rwsem(&c->wbuf_sem);
1273 c->wbuf_pagesize = MTD_PROGREGION_SIZE(c->mtd); 1273 c->wbuf_pagesize = c->mtd->writesize;
1274 c->wbuf_ofs = 0xFFFFFFFF; 1274 c->wbuf_ofs = 0xFFFFFFFF;
1275 1275
1276 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); 1276 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 73620ef83364..d48c7492392b 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -66,8 +66,12 @@ struct mtd_info {
66 * information below if they desire 66 * information below if they desire
67 */ 67 */
68 u_int32_t erasesize; 68 u_int32_t erasesize;
69 /* Smallest availlable size for writing to the device. For NAND,
70 * this is the page size, for some NOR chips, the size of ECC
71 * covered blocks.
72 */
73 u_int32_t writesize;
69 74
70 u_int32_t oobblock; // Size of OOB blocks (e.g. 512)
71 u_int32_t oobsize; // Amount of OOB data per block (e.g. 16) 75 u_int32_t oobsize; // Amount of OOB data per block (e.g. 16)
72 u_int32_t ecctype; 76 u_int32_t ecctype;
73 u_int32_t eccsize; 77 u_int32_t eccsize;
@@ -79,7 +83,6 @@ struct mtd_info {
79 * MTD_PROGRAM_REGIONS flag is set. 83 * MTD_PROGRAM_REGIONS flag is set.
80 * (Maybe we should have an union for those?) 84 * (Maybe we should have an union for those?)
81 */ 85 */
82#define MTD_PROGREGION_SIZE(mtd) (mtd)->oobblock
83#define MTD_PROGREGION_CTRLMODE_VALID(mtd) (mtd)->oobsize 86#define MTD_PROGREGION_CTRLMODE_VALID(mtd) (mtd)->oobsize
84#define MTD_PROGREGION_CTRLMODE_INVALID(mtd) (mtd)->ecctype 87#define MTD_PROGREGION_CTRLMODE_INVALID(mtd) (mtd)->ecctype
85 88
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
index e4d61f33d5bb..520a3b483100 100644
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -63,7 +63,7 @@ struct mtd_info_user {
63 uint32_t flags; 63 uint32_t flags;
64 uint32_t size; // Total size of the MTD 64 uint32_t size; // Total size of the MTD
65 uint32_t erasesize; 65 uint32_t erasesize;
66 uint32_t oobblock; // Size of OOB blocks (e.g. 512) 66 uint32_t writesize;
67 uint32_t oobsize; // Amount of OOB data per block (e.g. 16) 67 uint32_t oobsize; // Amount of OOB data per block (e.g. 16)
68 uint32_t ecctype; 68 uint32_t ecctype;
69 uint32_t eccsize; 69 uint32_t eccsize;