aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 06:37:31 -0400
committerThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 06:37:31 -0400
commit4cbb9b80e171107c6c34116283fe38e5a396c68b (patch)
tree9463f2e4774f14752cf4bb52431e14e569256f72
parent6dfc6d250d0b7ebaa6423c44dcd09fcfe68deabd (diff)
parent9fe4854cd1f60273f9a3ece053f4789605f58a5e (diff)
Merge branch 'master' of /home/tglx/work/kernel/git/mtd-2.6/
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c6
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c5
-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.c74
-rw-r--r--drivers/mtd/onenand/onenand_bbt.c4
-rw-r--r--fs/jffs2/dir.c40
-rw-r--r--fs/jffs2/erase.c4
-rw-r--r--fs/jffs2/file.c8
-rw-r--r--fs/jffs2/fs.c20
-rw-r--r--fs/jffs2/gc.c51
-rw-r--r--fs/jffs2/nodelist.c13
-rw-r--r--fs/jffs2/nodelist.h75
-rw-r--r--fs/jffs2/nodemgmt.c35
-rw-r--r--fs/jffs2/os-linux.h14
-rw-r--r--fs/jffs2/scan.c24
-rw-r--r--fs/jffs2/summary.c30
-rw-r--r--fs/jffs2/wbuf.c52
-rw-r--r--fs/jffs2/write.c85
-rw-r--r--fs/jffs2/xattr.c60
-rw-r--r--fs/jffs2/xattr.h14
-rw-r--r--include/linux/mtd/mtd.h7
-rw-r--r--include/mtd/mtd-abi.h15
32 files changed, 357 insertions, 415 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index d0d5e521b564..0d435814aaa1 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_BIT_WRITEABLE;
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/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index 3911c98ba578..fae70a5db540 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -238,9 +238,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
238 mtd->unlock = cfi_staa_unlock; 238 mtd->unlock = cfi_staa_unlock;
239 mtd->suspend = cfi_staa_suspend; 239 mtd->suspend = cfi_staa_suspend;
240 mtd->resume = cfi_staa_resume; 240 mtd->resume = cfi_staa_resume;
241 mtd->flags = MTD_CAP_NORFLASH; 241 mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE;
242 mtd->flags |= MTD_ECC; /* FIXME: Not all STMicro flashes have this */ 242 mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
243 mtd->eccsize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
244 map->fldrv = &cfi_staa_chipdrv; 243 map->fldrv = &cfi_staa_chipdrv;
245 __module_get(THIS_MODULE); 244 __module_get(THIS_MODULE);
246 mtd->name = map->name; 245 mtd->name = map->name;
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 d7f04abfe18e..29dde7dcafa1 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 128c937af32f..b771608ef84e 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 98792ec4c2dc..778535006c83 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -572,9 +572,9 @@ static void nand_command(struct mtd_info *mtd, unsigned command, int column,
572 if (command == NAND_CMD_SEQIN) { 572 if (command == NAND_CMD_SEQIN) {
573 int readcmd; 573 int readcmd;
574 574
575 if (column >= mtd->oobblock) { 575 if (column >= mtd->writesize) {
576 /* OOB area */ 576 /* OOB area */
577 column -= mtd->oobblock; 577 column -= mtd->writesize;
578 readcmd = NAND_CMD_READOOB; 578 readcmd = NAND_CMD_READOOB;
579 } else if (column < 256) { 579 } else if (column < 256) {
580 /* First 256 bytes --> READ0 */ 580 /* First 256 bytes --> READ0 */
@@ -670,7 +670,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column,
670 670
671 /* Emulate NAND_CMD_READOOB */ 671 /* Emulate NAND_CMD_READOOB */
672 if (command == NAND_CMD_READOOB) { 672 if (command == NAND_CMD_READOOB) {
673 column += mtd->oobblock; 673 column += mtd->writesize;
674 command = NAND_CMD_READ0; 674 command = NAND_CMD_READ0;
675 } 675 }
676 676
@@ -895,7 +895,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
895 /* No ecc, write all */ 895 /* No ecc, write all */
896 case NAND_ECC_NONE: 896 case NAND_ECC_NONE:
897 printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); 897 printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n");
898 this->write_buf(mtd, this->data_poi, mtd->oobblock); 898 this->write_buf(mtd, this->data_poi, mtd->writesize);
899 break; 899 break;
900 900
901 /* Software ecc 3/256, write all */ 901 /* Software ecc 3/256, write all */
@@ -906,7 +906,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
906 oob_buf[oob_config[eccidx]] = ecc_code[i]; 906 oob_buf[oob_config[eccidx]] = ecc_code[i];
907 datidx += this->ecc.size; 907 datidx += this->ecc.size;
908 } 908 }
909 this->write_buf(mtd, this->data_poi, mtd->oobblock); 909 this->write_buf(mtd, this->data_poi, mtd->writesize);
910 break; 910 break;
911 default: 911 default:
912 eccbytes = this->ecc.bytes; 912 eccbytes = this->ecc.bytes;
@@ -1167,9 +1167,9 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
1167 page = realpage & this->pagemask; 1167 page = realpage & this->pagemask;
1168 1168
1169 /* Get raw starting column */ 1169 /* Get raw starting column */
1170 col = from & (mtd->oobblock - 1); 1170 col = from & (mtd->writesize - 1);
1171 1171
1172 end = mtd->oobblock; 1172 end = mtd->writesize;
1173 ecc = this->ecc.size; 1173 ecc = this->ecc.size;
1174 eccbytes = this->ecc.bytes; 1174 eccbytes = this->ecc.bytes;
1175 1175
@@ -1327,7 +1327,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
1327 buf[read++] = data_poi[j]; 1327 buf[read++] = data_poi[j];
1328 this->pagebuf = realpage; 1328 this->pagebuf = realpage;
1329 } else 1329 } else
1330 read += mtd->oobblock; 1330 read += mtd->writesize;
1331 1331
1332 /* Apply delay or wait for ready/busy pin 1332 /* Apply delay or wait for ready/busy pin
1333 * Do this before the AUTOINCR check, so no problems 1333 * Do this before the AUTOINCR check, so no problems
@@ -1485,7 +1485,7 @@ int nand_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, s
1485 int chip = (int)(from >> this->chip_shift); 1485 int chip = (int)(from >> this->chip_shift);
1486 int sndcmd = 1; 1486 int sndcmd = 1;
1487 int cnt = 0; 1487 int cnt = 0;
1488 int pagesize = mtd->oobblock + mtd->oobsize; 1488 int pagesize = mtd->writesize + mtd->oobsize;
1489 int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; 1489 int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1;
1490 1490
1491 /* Do not allow reads past end of device */ 1491 /* Do not allow reads past end of device */
@@ -1587,7 +1587,7 @@ static uint8_t *nand_prepare_oobbuf(struct mtd_info *mtd, uint8_t *fsbuf, struct
1587 return this->oob_buf; 1587 return this->oob_buf;
1588} 1588}
1589 1589
1590#define NOTALIGNED(x) (x & (mtd->oobblock-1)) != 0 1590#define NOTALIGNED(x) (x & (mtd->writesize-1)) != 0
1591 1591
1592/** 1592/**
1593 * nand_write - [MTD Interface] compability function for nand_write_ecc 1593 * nand_write - [MTD Interface] compability function for nand_write_ecc
@@ -1700,7 +1700,7 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
1700 /* Next oob page */ 1700 /* Next oob page */
1701 oob += mtd->oobsize; 1701 oob += mtd->oobsize;
1702 /* Update written bytes count */ 1702 /* Update written bytes count */
1703 written += mtd->oobblock; 1703 written += mtd->writesize;
1704 if (written == len) 1704 if (written == len)
1705 goto cmp; 1705 goto cmp;
1706 1706
@@ -1811,7 +1811,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r
1811 1811
1812 if (NAND_MUST_PAD(this)) { 1812 if (NAND_MUST_PAD(this)) {
1813 /* Write out desired data */ 1813 /* Write out desired data */
1814 this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask); 1814 this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page & this->pagemask);
1815 /* prepad 0xff for partial programming */ 1815 /* prepad 0xff for partial programming */
1816 this->write_buf(mtd, ffchars, column); 1816 this->write_buf(mtd, ffchars, column);
1817 /* write data */ 1817 /* write data */
@@ -1820,7 +1820,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r
1820 this->write_buf(mtd, ffchars, mtd->oobsize - (len + column)); 1820 this->write_buf(mtd, ffchars, mtd->oobsize - (len + column));
1821 } else { 1821 } else {
1822 /* Write out desired data */ 1822 /* Write out desired data */
1823 this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask); 1823 this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize + column, page & this->pagemask);
1824 /* write data */ 1824 /* write data */
1825 this->write_buf(mtd, buf, len); 1825 this->write_buf(mtd, buf, len);
1826 } 1826 }
@@ -1953,7 +1953,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
1953 /* If the given tuple is >= pagesize then 1953 /* If the given tuple is >= pagesize then
1954 * write it out from the iov 1954 * write it out from the iov
1955 */ 1955 */
1956 if ((vecs->iov_len - len) >= mtd->oobblock) { 1956 if ((vecs->iov_len - len) >= mtd->writesize) {
1957 /* Calc number of pages we can write 1957 /* Calc number of pages we can write
1958 * out of this iov in one go */ 1958 * out of this iov in one go */
1959 numpages = (vecs->iov_len - len) >> this->page_shift; 1959 numpages = (vecs->iov_len - len) >> this->page_shift;
@@ -1973,8 +1973,8 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
1973 &oobbuf[oob], oobsel, i != numpages); 1973 &oobbuf[oob], oobsel, i != numpages);
1974 if (ret) 1974 if (ret)
1975 goto out; 1975 goto out;
1976 this->data_poi += mtd->oobblock; 1976 this->data_poi += mtd->writesize;
1977 len += mtd->oobblock; 1977 len += mtd->writesize;
1978 oob += mtd->oobsize; 1978 oob += mtd->oobsize;
1979 page++; 1979 page++;
1980 } 1980 }
@@ -1989,7 +1989,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
1989 * tuple until we have a full page to write 1989 * tuple until we have a full page to write
1990 */ 1990 */
1991 int cnt = 0; 1991 int cnt = 0;
1992 while (cnt < mtd->oobblock) { 1992 while (cnt < mtd->writesize) {
1993 if (vecs->iov_base != NULL && vecs->iov_len) 1993 if (vecs->iov_base != NULL && vecs->iov_len)
1994 this->data_buf[cnt++] = ((uint8_t *) vecs->iov_base)[len++]; 1994 this->data_buf[cnt++] = ((uint8_t *) vecs->iov_base)[len++];
1995 /* Check, if we have to switch to the next tuple */ 1995 /* Check, if we have to switch to the next tuple */
@@ -2015,7 +2015,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
2015 if (ret) 2015 if (ret)
2016 goto out; 2016 goto out;
2017 2017
2018 written += mtd->oobblock * numpages; 2018 written += mtd->writesize * numpages;
2019 /* All done ? */ 2019 /* All done ? */
2020 if (!count) 2020 if (!count)
2021 break; 2021 break;
@@ -2351,7 +2351,7 @@ static int nand_allocate_kmem(struct mtd_info *mtd, struct nand_chip *this)
2351 } 2351 }
2352 2352
2353 if (!this->data_buf) { 2353 if (!this->data_buf) {
2354 len = mtd->oobblock + mtd->oobsize; 2354 len = mtd->writesize + mtd->oobsize;
2355 this->data_buf = kmalloc(len, GFP_KERNEL); 2355 this->data_buf = kmalloc(len, GFP_KERNEL);
2356 if (!this->data_buf) 2356 if (!this->data_buf)
2357 goto outerr; 2357 goto outerr;
@@ -2455,10 +2455,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2455 /* The 4th id byte is the important one */ 2455 /* The 4th id byte is the important one */
2456 extid = this->read_byte(mtd); 2456 extid = this->read_byte(mtd);
2457 /* Calc pagesize */ 2457 /* Calc pagesize */
2458 mtd->oobblock = 1024 << (extid & 0x3); 2458 mtd->writesize = 1024 << (extid & 0x3);
2459 extid >>= 2; 2459 extid >>= 2;
2460 /* Calc oobsize */ 2460 /* Calc oobsize */
2461 mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9); 2461 mtd->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9);
2462 extid >>= 2; 2462 extid >>= 2;
2463 /* Calc blocksize. Blocksize is multiples of 64KiB */ 2463 /* Calc blocksize. Blocksize is multiples of 64KiB */
2464 mtd->erasesize = (64 * 1024) << (extid & 0x03); 2464 mtd->erasesize = (64 * 1024) << (extid & 0x03);
@@ -2471,8 +2471,8 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2471 * Old devices have this data hardcoded in the device id table 2471 * Old devices have this data hardcoded in the device id table
2472 */ 2472 */
2473 mtd->erasesize = nand_flash_ids[i].erasesize; 2473 mtd->erasesize = nand_flash_ids[i].erasesize;
2474 mtd->oobblock = nand_flash_ids[i].pagesize; 2474 mtd->writesize = nand_flash_ids[i].pagesize;
2475 mtd->oobsize = mtd->oobblock / 32; 2475 mtd->oobsize = mtd->writesize / 32;
2476 busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16; 2476 busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16;
2477 } 2477 }
2478 2478
@@ -2497,7 +2497,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2497 } 2497 }
2498 2498
2499 /* Calculate the address shift from the page size */ 2499 /* Calculate the address shift from the page size */
2500 this->page_shift = ffs(mtd->oobblock) - 1; 2500 this->page_shift = ffs(mtd->writesize) - 1;
2501 /* Convert chipsize to number of pages per chip -1. */ 2501 /* Convert chipsize to number of pages per chip -1. */
2502 this->pagemask = (this->chipsize >> this->page_shift) - 1; 2502 this->pagemask = (this->chipsize >> this->page_shift) - 1;
2503 2503
@@ -2506,7 +2506,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2506 this->chip_shift = ffs(this->chipsize) - 1; 2506 this->chip_shift = ffs(this->chipsize) - 1;
2507 2507
2508 /* Set the bad block position */ 2508 /* Set the bad block position */
2509 this->badblockpos = mtd->oobblock > 512 ? 2509 this->badblockpos = mtd->writesize > 512 ?
2510 NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; 2510 NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS;
2511 2511
2512 /* Get chip options, preserve non chip based options */ 2512 /* Get chip options, preserve non chip based options */
@@ -2531,7 +2531,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2531 this->erase_cmd = single_erase_cmd; 2531 this->erase_cmd = single_erase_cmd;
2532 2532
2533 /* Do not replace user supplied command function ! */ 2533 /* Do not replace user supplied command function ! */
2534 if (mtd->oobblock > 512 && this->cmdfunc == nand_command) 2534 if (mtd->writesize > 512 && this->cmdfunc == nand_command)
2535 this->cmdfunc = nand_command_lp; 2535 this->cmdfunc = nand_command_lp;
2536 2536
2537 printk(KERN_INFO "NAND device: Manufacturer ID:" 2537 printk(KERN_INFO "NAND device: Manufacturer ID:"
@@ -2657,11 +2657,11 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2657 "Hardware ECC not possible\n"); 2657 "Hardware ECC not possible\n");
2658 BUG(); 2658 BUG();
2659 } 2659 }
2660 if (mtd->oobblock >= this->ecc.size) 2660 if (mtd->writesize >= this->ecc.size)
2661 break; 2661 break;
2662 printk(KERN_WARNING "%d byte HW ECC not possible on " 2662 printk(KERN_WARNING "%d byte HW ECC not possible on "
2663 "%d byte page size, fallback to SW ECC\n", 2663 "%d byte page size, fallback to SW ECC\n",
2664 this->ecc.size, mtd->oobblock); 2664 this->ecc.size, mtd->writesize);
2665 this->ecc.mode = NAND_ECC_SOFT; 2665 this->ecc.mode = NAND_ECC_SOFT;
2666 2666
2667 case NAND_ECC_SOFT: 2667 case NAND_ECC_SOFT:
@@ -2674,7 +2674,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2674 case NAND_ECC_NONE: 2674 case NAND_ECC_NONE:
2675 printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. " 2675 printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. "
2676 "This is not recommended !!\n"); 2676 "This is not recommended !!\n");
2677 this->ecc.size = mtd->oobblock; 2677 this->ecc.size = mtd->writesize;
2678 this->ecc.bytes = 0; 2678 this->ecc.bytes = 0;
2679 break; 2679 break;
2680 default: 2680 default:
@@ -2687,8 +2687,8 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2687 * Set the number of read / write steps for one page depending on ECC 2687 * Set the number of read / write steps for one page depending on ECC
2688 * mode 2688 * mode
2689 */ 2689 */
2690 this->ecc.steps = mtd->oobblock / this->ecc.size; 2690 this->ecc.steps = mtd->writesize / this->ecc.size;
2691 if(this->ecc.steps * this->ecc.size != mtd->oobblock) { 2691 if(this->ecc.steps * this->ecc.size != mtd->writesize) {
2692 printk(KERN_WARNING "Invalid ecc parameters\n"); 2692 printk(KERN_WARNING "Invalid ecc parameters\n");
2693 BUG(); 2693 BUG();
2694 } 2694 }
@@ -2706,7 +2706,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
2706 2706
2707 /* Fill in remaining MTD driver data */ 2707 /* Fill in remaining MTD driver data */
2708 mtd->type = MTD_NANDFLASH; 2708 mtd->type = MTD_NANDFLASH;
2709 mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC; 2709 mtd->flags = MTD_CAP_NANDFLASH;
2710 mtd->ecctype = MTD_ECC_SW; 2710 mtd->ecctype = MTD_ECC_SW;
2711 mtd->erase = nand_erase; 2711 mtd->erase = nand_erase;
2712 mtd->point = NULL; 2712 mtd->point = NULL;
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 9008bc5493fb..22af9b29d2bf 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 a2122fe4101a..f8e631c89a60 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..4c2c61d54b3a 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");
@@ -1943,7 +1943,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1943 1943
1944 /* Fill in remaining MTD driver data */ 1944 /* Fill in remaining MTD driver data */
1945 mtd->type = MTD_NANDFLASH; 1945 mtd->type = MTD_NANDFLASH;
1946 mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC; 1946 mtd->flags = MTD_CAP_NANDFLASH;
1947 mtd->ecctype = MTD_ECC_SW; 1947 mtd->ecctype = MTD_ECC_SW;
1948 mtd->erase = onenand_erase; 1948 mtd->erase = onenand_erase;
1949 mtd->point = NULL; 1949 mtd->point = NULL;
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/dir.c b/fs/jffs2/dir.c
index ff1b7950dd44..edd8371fc6a5 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -308,7 +308,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
308 struct jffs2_full_dnode *fn; 308 struct jffs2_full_dnode *fn;
309 struct jffs2_full_dirent *fd; 309 struct jffs2_full_dirent *fd;
310 int namelen; 310 int namelen;
311 uint32_t alloclen, phys_ofs; 311 uint32_t alloclen;
312 int ret, targetlen = strlen(target); 312 int ret, targetlen = strlen(target);
313 313
314 /* FIXME: If you care. We'd need to use frags for the target 314 /* FIXME: If you care. We'd need to use frags for the target
@@ -327,8 +327,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
327 * Just the node will do for now, though 327 * Just the node will do for now, though
328 */ 328 */
329 namelen = dentry->d_name.len; 329 namelen = dentry->d_name.len;
330 ret = jffs2_reserve_space(c, sizeof(*ri) + targetlen, &phys_ofs, &alloclen, 330 ret = jffs2_reserve_space(c, sizeof(*ri) + targetlen, &alloclen,
331 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); 331 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
332 332
333 if (ret) { 333 if (ret) {
334 jffs2_free_raw_inode(ri); 334 jffs2_free_raw_inode(ri);
@@ -356,7 +356,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
356 ri->data_crc = cpu_to_je32(crc32(0, target, targetlen)); 356 ri->data_crc = cpu_to_je32(crc32(0, target, targetlen));
357 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); 357 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
358 358
359 fn = jffs2_write_dnode(c, f, ri, target, targetlen, phys_ofs, ALLOC_NORMAL); 359 fn = jffs2_write_dnode(c, f, ri, target, targetlen, ALLOC_NORMAL);
360 360
361 jffs2_free_raw_inode(ri); 361 jffs2_free_raw_inode(ri);
362 362
@@ -400,8 +400,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
400 return ret; 400 return ret;
401 } 401 }
402 402
403 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, 403 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
404 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 404 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
405 if (ret) { 405 if (ret) {
406 /* Eep. */ 406 /* Eep. */
407 jffs2_clear_inode(inode); 407 jffs2_clear_inode(inode);
@@ -433,7 +433,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
433 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); 433 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
434 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); 434 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
435 435
436 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); 436 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, ALLOC_NORMAL);
437 437
438 if (IS_ERR(fd)) { 438 if (IS_ERR(fd)) {
439 /* dirent failed to write. Delete the inode normally 439 /* dirent failed to write. Delete the inode normally
@@ -471,7 +471,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
471 struct jffs2_full_dnode *fn; 471 struct jffs2_full_dnode *fn;
472 struct jffs2_full_dirent *fd; 472 struct jffs2_full_dirent *fd;
473 int namelen; 473 int namelen;
474 uint32_t alloclen, phys_ofs; 474 uint32_t alloclen;
475 int ret; 475 int ret;
476 476
477 mode |= S_IFDIR; 477 mode |= S_IFDIR;
@@ -486,8 +486,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
486 * Just the node will do for now, though 486 * Just the node will do for now, though
487 */ 487 */
488 namelen = dentry->d_name.len; 488 namelen = dentry->d_name.len;
489 ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL, 489 ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL,
490 JFFS2_SUMMARY_INODE_SIZE); 490 JFFS2_SUMMARY_INODE_SIZE);
491 491
492 if (ret) { 492 if (ret) {
493 jffs2_free_raw_inode(ri); 493 jffs2_free_raw_inode(ri);
@@ -512,7 +512,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
512 ri->data_crc = cpu_to_je32(0); 512 ri->data_crc = cpu_to_je32(0);
513 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); 513 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
514 514
515 fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, ALLOC_NORMAL); 515 fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL);
516 516
517 jffs2_free_raw_inode(ri); 517 jffs2_free_raw_inode(ri);
518 518
@@ -542,8 +542,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
542 return ret; 542 return ret;
543 } 543 }
544 544
545 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, 545 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
546 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 546 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
547 if (ret) { 547 if (ret) {
548 /* Eep. */ 548 /* Eep. */
549 jffs2_clear_inode(inode); 549 jffs2_clear_inode(inode);
@@ -575,7 +575,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
575 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); 575 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
576 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); 576 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
577 577
578 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); 578 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, ALLOC_NORMAL);
579 579
580 if (IS_ERR(fd)) { 580 if (IS_ERR(fd)) {
581 /* dirent failed to write. Delete the inode normally 581 /* dirent failed to write. Delete the inode normally
@@ -631,7 +631,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
631 int namelen; 631 int namelen;
632 union jffs2_device_node dev; 632 union jffs2_device_node dev;
633 int devlen = 0; 633 int devlen = 0;
634 uint32_t alloclen, phys_ofs; 634 uint32_t alloclen;
635 int ret; 635 int ret;
636 636
637 if (!new_valid_dev(rdev)) 637 if (!new_valid_dev(rdev))
@@ -650,7 +650,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
650 * Just the node will do for now, though 650 * Just the node will do for now, though
651 */ 651 */
652 namelen = dentry->d_name.len; 652 namelen = dentry->d_name.len;
653 ret = jffs2_reserve_space(c, sizeof(*ri) + devlen, &phys_ofs, &alloclen, 653 ret = jffs2_reserve_space(c, sizeof(*ri) + devlen, &alloclen,
654 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); 654 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
655 655
656 if (ret) { 656 if (ret) {
@@ -678,7 +678,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
678 ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen)); 678 ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen));
679 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); 679 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
680 680
681 fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, phys_ofs, ALLOC_NORMAL); 681 fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, ALLOC_NORMAL);
682 682
683 jffs2_free_raw_inode(ri); 683 jffs2_free_raw_inode(ri);
684 684
@@ -708,8 +708,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
708 return ret; 708 return ret;
709 } 709 }
710 710
711 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, 711 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
712 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 712 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
713 if (ret) { 713 if (ret) {
714 /* Eep. */ 714 /* Eep. */
715 jffs2_clear_inode(inode); 715 jffs2_clear_inode(inode);
@@ -744,7 +744,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
744 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); 744 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
745 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); 745 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
746 746
747 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); 747 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, ALLOC_NORMAL);
748 748
749 if (IS_ERR(fd)) { 749 if (IS_ERR(fd)) {
750 /* dirent failed to write. Delete the inode normally 750 /* dirent failed to write. Delete the inode normally
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index f677d6950fd4..4616fed75730 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -230,6 +230,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
230 at the end of the linked list. Stash it and continue 230 at the end of the linked list. Stash it and continue
231 from the beginning of the list */ 231 from the beginning of the list */
232 ic = (struct jffs2_inode_cache *)(*prev); 232 ic = (struct jffs2_inode_cache *)(*prev);
233 BUG_ON(ic->class != RAWNODE_CLASS_INODE_CACHE);
233 prev = &ic->nodes; 234 prev = &ic->nodes;
234 continue; 235 continue;
235 } 236 }
@@ -410,10 +411,9 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
410 /* Everything else got zeroed before the erase */ 411 /* Everything else got zeroed before the erase */
411 jeb->free_size = c->sector_size; 412 jeb->free_size = c->sector_size;
412 413
413 marker_ref->next_in_ino = NULL;
414 marker_ref->flash_offset = jeb->offset | REF_NORMAL; 414 marker_ref->flash_offset = jeb->offset | REF_NORMAL;
415 415
416 jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size); 416 jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size, NULL);
417 } 417 }
418 418
419 spin_lock(&c->erase_completion_lock); 419 spin_lock(&c->erase_completion_lock);
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index e18c9437d58f..bb8844f40e48 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -134,13 +134,13 @@ static int jffs2_prepare_write (struct file *filp, struct page *pg,
134 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); 134 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
135 struct jffs2_raw_inode ri; 135 struct jffs2_raw_inode ri;
136 struct jffs2_full_dnode *fn; 136 struct jffs2_full_dnode *fn;
137 uint32_t phys_ofs, alloc_len; 137 uint32_t alloc_len;
138 138
139 D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", 139 D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
140 (unsigned int)inode->i_size, pageofs)); 140 (unsigned int)inode->i_size, pageofs));
141 141
142 ret = jffs2_reserve_space(c, sizeof(ri), &phys_ofs, &alloc_len, 142 ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
143 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); 143 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
144 if (ret) 144 if (ret)
145 return ret; 145 return ret;
146 146
@@ -166,7 +166,7 @@ static int jffs2_prepare_write (struct file *filp, struct page *pg,
166 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); 166 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
167 ri.data_crc = cpu_to_je32(0); 167 ri.data_crc = cpu_to_je32(0);
168 168
169 fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_NORMAL); 169 fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_NORMAL);
170 170
171 if (IS_ERR(fn)) { 171 if (IS_ERR(fn)) {
172 ret = PTR_ERR(fn); 172 ret = PTR_ERR(fn);
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index a0f84673ce54..7b6c24b14f85 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -37,7 +37,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
37 unsigned char *mdata = NULL; 37 unsigned char *mdata = NULL;
38 int mdatalen = 0; 38 int mdatalen = 0;
39 unsigned int ivalid; 39 unsigned int ivalid;
40 uint32_t phys_ofs, alloclen; 40 uint32_t alloclen;
41 int ret; 41 int ret;
42 D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); 42 D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino));
43 ret = inode_change_ok(inode, iattr); 43 ret = inode_change_ok(inode, iattr);
@@ -79,8 +79,8 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
79 return -ENOMEM; 79 return -ENOMEM;
80 } 80 }
81 81
82 ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &phys_ofs, &alloclen, 82 ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &alloclen,
83 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); 83 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
84 if (ret) { 84 if (ret) {
85 jffs2_free_raw_inode(ri); 85 jffs2_free_raw_inode(ri);
86 if (S_ISLNK(inode->i_mode & S_IFMT)) 86 if (S_ISLNK(inode->i_mode & S_IFMT))
@@ -131,7 +131,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
131 else 131 else
132 ri->data_crc = cpu_to_je32(0); 132 ri->data_crc = cpu_to_je32(0);
133 133
134 new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, ALLOC_NORMAL); 134 new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, ALLOC_NORMAL);
135 if (S_ISLNK(inode->i_mode)) 135 if (S_ISLNK(inode->i_mode))
136 kfree(mdata); 136 kfree(mdata);
137 137
@@ -664,13 +664,6 @@ static int jffs2_flash_setup(struct jffs2_sb_info *c) {
664 return ret; 664 return ret;
665 } 665 }
666 666
667 /* add setups for other bizarre flashes here... */
668 if (jffs2_nor_ecc(c)) {
669 ret = jffs2_nor_ecc_flash_setup(c);
670 if (ret)
671 return ret;
672 }
673
674 /* and Dataflash */ 667 /* and Dataflash */
675 if (jffs2_dataflash(c)) { 668 if (jffs2_dataflash(c)) {
676 ret = jffs2_dataflash_setup(c); 669 ret = jffs2_dataflash_setup(c);
@@ -694,11 +687,6 @@ void jffs2_flash_cleanup(struct jffs2_sb_info *c) {
694 jffs2_nand_flash_cleanup(c); 687 jffs2_nand_flash_cleanup(c);
695 } 688 }
696 689
697 /* add cleanups for other bizarre flashes here... */
698 if (jffs2_nor_ecc(c)) {
699 jffs2_nor_ecc_flash_cleanup(c);
700 }
701
702 /* and DataFlash */ 690 /* and DataFlash */
703 if (jffs2_dataflash(c)) { 691 if (jffs2_dataflash(c)) {
704 jffs2_dataflash_cleanup(c); 692 jffs2_dataflash_cleanup(c);
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index 4773ba24304f..f9e982a65ac2 100644
--- a/fs/jffs2/gc.c
+++ b/fs/jffs2/gc.c
@@ -545,7 +545,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
545 if (ic && alloclen > sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN) 545 if (ic && alloclen > sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN)
546 alloclen = sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN; 546 alloclen = sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN;
547 547
548 ret = jffs2_reserve_space_gc(c, alloclen, &phys_ofs, &alloclen, rawlen); 548 ret = jffs2_reserve_space_gc(c, alloclen, &alloclen, rawlen);
549 /* 'rawlen' is not the exact summary size; it is only an upper estimation */ 549 /* 'rawlen' is not the exact summary size; it is only an upper estimation */
550 550
551 if (ret) 551 if (ret)
@@ -626,19 +626,16 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
626 626
627 /* OK, all the CRCs are good; this node can just be copied as-is. */ 627 /* OK, all the CRCs are good; this node can just be copied as-is. */
628 retry: 628 retry:
629 nraw->flash_offset = phys_ofs; 629 nraw->flash_offset = phys_ofs = write_ofs(c);
630 630
631 ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); 631 ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node);
632 632
633 if (ret || (retlen != rawlen)) { 633 if (ret || (retlen != rawlen)) {
634 printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", 634 printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n",
635 rawlen, phys_ofs, ret, retlen); 635 rawlen, nraw->flash_offset, ret, retlen);
636 if (retlen) { 636 if (retlen) {
637 /* Doesn't belong to any inode */
638 nraw->next_in_ino = NULL;
639
640 nraw->flash_offset |= REF_OBSOLETE; 637 nraw->flash_offset |= REF_OBSOLETE;
641 jffs2_add_physical_node_ref(c, nraw, rawlen); 638 jffs2_add_physical_node_ref(c, nraw, rawlen, NULL);
642 jffs2_mark_node_obsolete(c, nraw); 639 jffs2_mark_node_obsolete(c, nraw);
643 } else { 640 } else {
644 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset); 641 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset);
@@ -656,7 +653,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
656 jffs2_dbg_acct_sanity_check(c,jeb); 653 jffs2_dbg_acct_sanity_check(c,jeb);
657 jffs2_dbg_acct_paranoia_check(c, jeb); 654 jffs2_dbg_acct_paranoia_check(c, jeb);
658 655
659 ret = jffs2_reserve_space_gc(c, rawlen, &phys_ofs, &dummy, rawlen); 656 ret = jffs2_reserve_space_gc(c, rawlen, &dummy, rawlen);
660 /* this is not the exact summary size of it, 657 /* this is not the exact summary size of it,
661 it is only an upper estimation */ 658 it is only an upper estimation */
662 659
@@ -678,18 +675,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
678 goto out_node; 675 goto out_node;
679 } 676 }
680 nraw->flash_offset |= REF_PRISTINE; 677 nraw->flash_offset |= REF_PRISTINE;
681 jffs2_add_physical_node_ref(c, nraw, rawlen); 678 jffs2_add_physical_node_ref(c, nraw, rawlen, ic);
682 679
683 if (ic) {
684 /* Link into per-inode list. This is safe because of the ic
685 state being INO_STATE_GC. Note that if we're doing this
686 for an inode which is in-core, the 'nraw' pointer is then
687 going to be fetched from ic->nodes by our caller. */
688 spin_lock(&c->erase_completion_lock);
689 nraw->next_in_ino = ic->nodes;
690 ic->nodes = nraw;
691 spin_unlock(&c->erase_completion_lock);
692 }
693 jffs2_mark_node_obsolete(c, raw); 680 jffs2_mark_node_obsolete(c, raw);
694 D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); 681 D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw)));
695 682
@@ -709,7 +696,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
709 struct jffs2_node_frag *last_frag; 696 struct jffs2_node_frag *last_frag;
710 union jffs2_device_node dev; 697 union jffs2_device_node dev;
711 char *mdata = NULL, mdatalen = 0; 698 char *mdata = NULL, mdatalen = 0;
712 uint32_t alloclen, phys_ofs, ilen; 699 uint32_t alloclen, ilen;
713 int ret; 700 int ret;
714 701
715 if (S_ISBLK(JFFS2_F_I_MODE(f)) || 702 if (S_ISBLK(JFFS2_F_I_MODE(f)) ||
@@ -735,7 +722,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
735 722
736 } 723 }
737 724
738 ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &phys_ofs, &alloclen, 725 ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &alloclen,
739 JFFS2_SUMMARY_INODE_SIZE); 726 JFFS2_SUMMARY_INODE_SIZE);
740 if (ret) { 727 if (ret) {
741 printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", 728 printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n",
@@ -773,7 +760,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
773 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); 760 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
774 ri.data_crc = cpu_to_je32(crc32(0, mdata, mdatalen)); 761 ri.data_crc = cpu_to_je32(crc32(0, mdata, mdatalen));
775 762
776 new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, phys_ofs, ALLOC_GC); 763 new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, ALLOC_GC);
777 764
778 if (IS_ERR(new_fn)) { 765 if (IS_ERR(new_fn)) {
779 printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); 766 printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn));
@@ -794,7 +781,7 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er
794{ 781{
795 struct jffs2_full_dirent *new_fd; 782 struct jffs2_full_dirent *new_fd;
796 struct jffs2_raw_dirent rd; 783 struct jffs2_raw_dirent rd;
797 uint32_t alloclen, phys_ofs; 784 uint32_t alloclen;
798 int ret; 785 int ret;
799 786
800 rd.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 787 rd.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -816,14 +803,14 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er
816 rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8)); 803 rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8));
817 rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize)); 804 rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize));
818 805
819 ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &phys_ofs, &alloclen, 806 ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &alloclen,
820 JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); 807 JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize));
821 if (ret) { 808 if (ret) {
822 printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", 809 printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n",
823 sizeof(rd)+rd.nsize, ret); 810 sizeof(rd)+rd.nsize, ret);
824 return ret; 811 return ret;
825 } 812 }
826 new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, phys_ofs, ALLOC_GC); 813 new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, ALLOC_GC);
827 814
828 if (IS_ERR(new_fd)) { 815 if (IS_ERR(new_fd)) {
829 printk(KERN_WARNING "jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd)); 816 printk(KERN_WARNING "jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd));
@@ -951,7 +938,7 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras
951 struct jffs2_raw_inode ri; 938 struct jffs2_raw_inode ri;
952 struct jffs2_node_frag *frag; 939 struct jffs2_node_frag *frag;
953 struct jffs2_full_dnode *new_fn; 940 struct jffs2_full_dnode *new_fn;
954 uint32_t alloclen, phys_ofs, ilen; 941 uint32_t alloclen, ilen;
955 int ret; 942 int ret;
956 943
957 D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", 944 D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n",
@@ -1030,14 +1017,14 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras
1030 ri.data_crc = cpu_to_je32(0); 1017 ri.data_crc = cpu_to_je32(0);
1031 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); 1018 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
1032 1019
1033 ret = jffs2_reserve_space_gc(c, sizeof(ri), &phys_ofs, &alloclen, 1020 ret = jffs2_reserve_space_gc(c, sizeof(ri), &alloclen,
1034 JFFS2_SUMMARY_INODE_SIZE); 1021 JFFS2_SUMMARY_INODE_SIZE);
1035 if (ret) { 1022 if (ret) {
1036 printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", 1023 printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n",
1037 sizeof(ri), ret); 1024 sizeof(ri), ret);
1038 return ret; 1025 return ret;
1039 } 1026 }
1040 new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_GC); 1027 new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_GC);
1041 1028
1042 if (IS_ERR(new_fn)) { 1029 if (IS_ERR(new_fn)) {
1043 printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn)); 1030 printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn));
@@ -1099,7 +1086,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
1099{ 1086{
1100 struct jffs2_full_dnode *new_fn; 1087 struct jffs2_full_dnode *new_fn;
1101 struct jffs2_raw_inode ri; 1088 struct jffs2_raw_inode ri;
1102 uint32_t alloclen, phys_ofs, offset, orig_end, orig_start; 1089 uint32_t alloclen, offset, orig_end, orig_start;
1103 int ret = 0; 1090 int ret = 0;
1104 unsigned char *comprbuf = NULL, *writebuf; 1091 unsigned char *comprbuf = NULL, *writebuf;
1105 unsigned long pg; 1092 unsigned long pg;
@@ -1256,7 +1243,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
1256 uint32_t cdatalen; 1243 uint32_t cdatalen;
1257 uint16_t comprtype = JFFS2_COMPR_NONE; 1244 uint16_t comprtype = JFFS2_COMPR_NONE;
1258 1245
1259 ret = jffs2_reserve_space_gc(c, sizeof(ri) + JFFS2_MIN_DATA_LEN, &phys_ofs, 1246 ret = jffs2_reserve_space_gc(c, sizeof(ri) + JFFS2_MIN_DATA_LEN,
1260 &alloclen, JFFS2_SUMMARY_INODE_SIZE); 1247 &alloclen, JFFS2_SUMMARY_INODE_SIZE);
1261 1248
1262 if (ret) { 1249 if (ret) {
@@ -1293,7 +1280,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
1293 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); 1280 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
1294 ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen)); 1281 ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen));
1295 1282
1296 new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, phys_ofs, ALLOC_GC); 1283 new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, ALLOC_GC);
1297 1284
1298 jffs2_free_comprbuf(comprbuf, writebuf); 1285 jffs2_free_comprbuf(comprbuf, writebuf);
1299 1286
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index 7d563f938b1c..d25d4919ca97 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -1048,7 +1048,8 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
1048} 1048}
1049 1049
1050void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 1050void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
1051 struct jffs2_raw_node_ref *ref, uint32_t len) 1051 struct jffs2_raw_node_ref *ref, uint32_t len,
1052 struct jffs2_inode_cache *ic)
1052{ 1053{
1053 if (!jeb->first_node) 1054 if (!jeb->first_node)
1054 jeb->first_node = ref; 1055 jeb->first_node = ref;
@@ -1065,6 +1066,13 @@ void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
1065 } 1066 }
1066 jeb->last_node = ref; 1067 jeb->last_node = ref;
1067 1068
1069 if (ic) {
1070 ref->next_in_ino = ic->nodes;
1071 ic->nodes = ref;
1072 } else {
1073 ref->next_in_ino = NULL;
1074 }
1075
1068 switch(ref_flags(ref)) { 1076 switch(ref_flags(ref)) {
1069 case REF_UNCHECKED: 1077 case REF_UNCHECKED:
1070 c->unchecked_size += len; 1078 c->unchecked_size += len;
@@ -1120,12 +1128,11 @@ int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
1120 1128
1121 ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size; 1129 ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size;
1122 ref->flash_offset |= REF_OBSOLETE; 1130 ref->flash_offset |= REF_OBSOLETE;
1123 ref->next_in_ino = 0;
1124#ifdef TEST_TOTLEN 1131#ifdef TEST_TOTLEN
1125 ref->__totlen = size; 1132 ref->__totlen = size;
1126#endif 1133#endif
1127 1134
1128 jffs2_link_node_ref(c, jeb, ref, size); 1135 jffs2_link_node_ref(c, jeb, ref, size, NULL);
1129 } 1136 }
1130 1137
1131 return 0; 1138 return 0;
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
index 80d1fda2212b..76f1b9419eea 100644
--- a/fs/jffs2/nodelist.h
+++ b/fs/jffs2/nodelist.h
@@ -77,9 +77,9 @@
77struct jffs2_raw_node_ref 77struct jffs2_raw_node_ref
78{ 78{
79 struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref 79 struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref
80 for this inode. If this is the last, it points to the inode_cache 80 for this object. If this _is_ the last, it points to the inode_cache,
81 for this inode instead. The inode_cache will have NULL in the first 81 xattr_ref or xattr_datum instead. The common part of those structures
82 word so you know when you've got there :) */ 82 has NULL in the first word. See jffs2_raw_ref_to_ic() below */
83 struct jffs2_raw_node_ref *next_phys; 83 struct jffs2_raw_node_ref *next_phys;
84 uint32_t flash_offset; 84 uint32_t flash_offset;
85#define TEST_TOTLEN 85#define TEST_TOTLEN
@@ -88,6 +88,18 @@ struct jffs2_raw_node_ref
88#endif 88#endif
89}; 89};
90 90
91static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw)
92{
93 while(raw->next_in_ino) {
94 raw = raw->next_in_ino;
95 }
96
97 /* NB. This can be a jffs2_xattr_datum or jffs2_xattr_ref and
98 not actually a jffs2_inode_cache. Check ->class */
99 return ((struct jffs2_inode_cache *)raw);
100}
101
102
91 /* flash_offset & 3 always has to be zero, because nodes are 103 /* flash_offset & 3 always has to be zero, because nodes are
92 always aligned at 4 bytes. So we have a couple of extra bits 104 always aligned at 4 bytes. So we have a couple of extra bits
93 to play with, which indicate the node's status; see below: */ 105 to play with, which indicate the node's status; see below: */
@@ -113,20 +125,27 @@ struct jffs2_raw_node_ref
113 a pointer to the first physical node which is part of this inode, too. 125 a pointer to the first physical node which is part of this inode, too.
114*/ 126*/
115struct jffs2_inode_cache { 127struct jffs2_inode_cache {
128 /* First part of structure is shared with other objects which
129 can terminate the raw node refs' next_in_ino list -- which
130 currently struct jffs2_xattr_datum and struct jffs2_xattr_ref. */
131
116 struct jffs2_full_dirent *scan_dents; /* Used during scan to hold 132 struct jffs2_full_dirent *scan_dents; /* Used during scan to hold
117 temporary lists of dirents, and later must be set to 133 temporary lists of dirents, and later must be set to
118 NULL to mark the end of the raw_node_ref->next_in_ino 134 NULL to mark the end of the raw_node_ref->next_in_ino
119 chain. */ 135 chain. */
120 u8 class; /* It's used for identification */
121 u8 flags;
122 uint16_t state;
123 struct jffs2_inode_cache *next;
124 struct jffs2_raw_node_ref *nodes; 136 struct jffs2_raw_node_ref *nodes;
137 uint8_t class; /* It's used for identification */
138
139 /* end of shared structure */
140
141 uint8_t flags;
142 uint16_t state;
125 uint32_t ino; 143 uint32_t ino;
126 int nlink; 144 struct jffs2_inode_cache *next;
127#ifdef CONFIG_JFFS2_FS_XATTR 145#ifdef CONFIG_JFFS2_FS_XATTR
128 struct jffs2_xattr_ref *xref; 146 struct jffs2_xattr_ref *xref;
129#endif 147#endif
148 int nlink;
130}; 149};
131 150
132/* Inode states for 'state' above. We need the 'GC' state to prevent 151/* Inode states for 'state' above. We need the 'GC' state to prevent
@@ -148,6 +167,8 @@ struct jffs2_inode_cache {
148 167
149#define INOCACHE_HASHSIZE 128 168#define INOCACHE_HASHSIZE 128
150 169
170#define write_ofs(c) ((c)->nextblock->offset + (c)->sector_size - (c)->nextblock->free_size)
171
151/* 172/*
152 Larger representation of a raw node, kept in-core only when the 173 Larger representation of a raw node, kept in-core only when the
153 struct inode for this particular ino is instantiated. 174 struct inode for this particular ino is instantiated.
@@ -250,15 +271,6 @@ static inline int jffs2_encode_dev(union jffs2_device_node *jdev, dev_t rdev)
250 } 271 }
251} 272}
252 273
253static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw)
254{
255 while(raw->next_in_ino) {
256 raw = raw->next_in_ino;
257 }
258
259 return ((struct jffs2_inode_cache *)raw);
260}
261
262static inline struct jffs2_node_frag *frag_first(struct rb_root *root) 274static inline struct jffs2_node_frag *frag_first(struct rb_root *root)
263{ 275{
264 struct rb_node *node = root->rb_node; 276 struct rb_node *node = root->rb_node;
@@ -307,32 +319,43 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
307void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size); 319void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size);
308int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn); 320int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn);
309void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 321void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
310 struct jffs2_raw_node_ref *ref, uint32_t len); 322 struct jffs2_raw_node_ref *ref, uint32_t len,
323 struct jffs2_inode_cache *ic);
311extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c, 324extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c,
312 struct jffs2_eraseblock *jeb, 325 struct jffs2_eraseblock *jeb,
313 struct jffs2_raw_node_ref *ref); 326 struct jffs2_raw_node_ref *ref);
314 327
315/* nodemgmt.c */ 328/* nodemgmt.c */
316int jffs2_thread_should_wake(struct jffs2_sb_info *c); 329int jffs2_thread_should_wake(struct jffs2_sb_info *c);
317int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, 330int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
318 uint32_t *len, int prio, uint32_t sumsize); 331 uint32_t *len, int prio, uint32_t sumsize);
319int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, 332int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
320 uint32_t *len, uint32_t sumsize); 333 uint32_t *len, uint32_t sumsize);
321int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len); 334int jffs2_add_physical_node_ref(struct jffs2_sb_info *c,
335 struct jffs2_raw_node_ref *new,
336 uint32_t len,
337 struct jffs2_inode_cache *ic);
322void jffs2_complete_reservation(struct jffs2_sb_info *c); 338void jffs2_complete_reservation(struct jffs2_sb_info *c);
323void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); 339void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw);
324 340
325/* write.c */ 341/* write.c */
326int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri); 342int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri);
327 343
328struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode); 344struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
329struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs, int alloc_mode); 345 struct jffs2_raw_inode *ri, const unsigned char *data,
346 uint32_t datalen, int alloc_mode);
347struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
348 struct jffs2_raw_dirent *rd, const unsigned char *name,
349 uint32_t namelen, int alloc_mode);
330int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 350int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
331 struct jffs2_raw_inode *ri, unsigned char *buf, 351 struct jffs2_raw_inode *ri, unsigned char *buf,
332 uint32_t offset, uint32_t writelen, uint32_t *retlen); 352 uint32_t offset, uint32_t writelen, uint32_t *retlen);
333int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const char *name, int namelen); 353int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f,
334int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, const char *name, int namelen, struct jffs2_inode_info *dead_f, uint32_t time); 354 struct jffs2_raw_inode *ri, const char *name, int namelen);
335int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint32_t ino, uint8_t type, const char *name, int namelen, uint32_t time); 355int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, const char *name,
356 int namelen, struct jffs2_inode_info *dead_f, uint32_t time);
357int jffs2_do_link(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint32_t ino,
358 uint8_t type, const char *name, int namelen, uint32_t time);
336 359
337 360
338/* readinode.c */ 361/* readinode.c */
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index 9a0f312cfcda..8feb8749bc75 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -23,13 +23,12 @@
23 * jffs2_reserve_space - request physical space to write nodes to flash 23 * jffs2_reserve_space - request physical space to write nodes to flash
24 * @c: superblock info 24 * @c: superblock info
25 * @minsize: Minimum acceptable size of allocation 25 * @minsize: Minimum acceptable size of allocation
26 * @ofs: Returned value of node offset
27 * @len: Returned value of allocation length 26 * @len: Returned value of allocation length
28 * @prio: Allocation type - ALLOC_{NORMAL,DELETION} 27 * @prio: Allocation type - ALLOC_{NORMAL,DELETION}
29 * 28 *
30 * Requests a block of physical space on the flash. Returns zero for success 29 * Requests a block of physical space on the flash. Returns zero for success
31 * and puts 'ofs' and 'len' into the appriopriate place, or returns -ENOSPC 30 * and puts 'len' into the appropriate place, or returns -ENOSPC or other
32 * or other error if appropriate. 31 * error if appropriate. Doesn't return len since that's
33 * 32 *
34 * If it returns zero, jffs2_reserve_space() also downs the per-filesystem 33 * If it returns zero, jffs2_reserve_space() also downs the per-filesystem
35 * allocation semaphore, to prevent more than one allocation from being 34 * allocation semaphore, to prevent more than one allocation from being
@@ -40,9 +39,9 @@
40 */ 39 */
41 40
42static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, 41static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
43 uint32_t *ofs, uint32_t *len, uint32_t sumsize); 42 uint32_t *len, uint32_t sumsize);
44 43
45int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, 44int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
46 uint32_t *len, int prio, uint32_t sumsize) 45 uint32_t *len, int prio, uint32_t sumsize)
47{ 46{
48 int ret = -EAGAIN; 47 int ret = -EAGAIN;
@@ -132,7 +131,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs
132 spin_lock(&c->erase_completion_lock); 131 spin_lock(&c->erase_completion_lock);
133 } 132 }
134 133
135 ret = jffs2_do_reserve_space(c, minsize, ofs, len, sumsize); 134 ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
136 if (ret) { 135 if (ret) {
137 D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret)); 136 D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret));
138 } 137 }
@@ -143,8 +142,8 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs
143 return ret; 142 return ret;
144} 143}
145 144
146int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, 145int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
147 uint32_t *len, uint32_t sumsize) 146 uint32_t *len, uint32_t sumsize)
148{ 147{
149 int ret = -EAGAIN; 148 int ret = -EAGAIN;
150 minsize = PAD(minsize); 149 minsize = PAD(minsize);
@@ -153,7 +152,7 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *
153 152
154 spin_lock(&c->erase_completion_lock); 153 spin_lock(&c->erase_completion_lock);
155 while(ret == -EAGAIN) { 154 while(ret == -EAGAIN) {
156 ret = jffs2_do_reserve_space(c, minsize, ofs, len, sumsize); 155 ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
157 if (ret) { 156 if (ret) {
158 D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); 157 D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret));
159 } 158 }
@@ -259,10 +258,11 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c)
259} 258}
260 259
261/* Called with alloc sem _and_ erase_completion_lock */ 260/* Called with alloc sem _and_ erase_completion_lock */
262static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len, uint32_t sumsize) 261static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
262 uint32_t *len, uint32_t sumsize)
263{ 263{
264 struct jffs2_eraseblock *jeb = c->nextblock; 264 struct jffs2_eraseblock *jeb = c->nextblock;
265 uint32_t reserved_size; /* for summary information at the end of the jeb */ 265 uint32_t reserved_size; /* for summary information at the end of the jeb */
266 int ret; 266 int ret;
267 267
268 restart: 268 restart:
@@ -349,7 +349,6 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
349 } 349 }
350 /* OK, jeb (==c->nextblock) is now pointing at a block which definitely has 350 /* OK, jeb (==c->nextblock) is now pointing at a block which definitely has
351 enough space */ 351 enough space */
352 *ofs = jeb->offset + (c->sector_size - jeb->free_size);
353 *len = jeb->free_size - reserved_size; 352 *len = jeb->free_size - reserved_size;
354 353
355 if (c->cleanmarker_size && jeb->used_size == c->cleanmarker_size && 354 if (c->cleanmarker_size && jeb->used_size == c->cleanmarker_size &&
@@ -365,7 +364,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
365 spin_lock(&c->erase_completion_lock); 364 spin_lock(&c->erase_completion_lock);
366 } 365 }
367 366
368 D1(printk(KERN_DEBUG "jffs2_do_reserve_space(): Giving 0x%x bytes at 0x%x\n", *len, *ofs)); 367 D1(printk(KERN_DEBUG "jffs2_do_reserve_space(): Giving 0x%x bytes at 0x%x\n",
368 *len, jeb->offset + (c->sector_size - jeb->free_size)));
369 return 0; 369 return 0;
370} 370}
371 371
@@ -381,7 +381,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
381 * Must be called with the alloc_sem held. 381 * Must be called with the alloc_sem held.
382 */ 382 */
383 383
384int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len) 384int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new,
385 uint32_t len, struct jffs2_inode_cache *ic)
385{ 386{
386 struct jffs2_eraseblock *jeb; 387 struct jffs2_eraseblock *jeb;
387 388
@@ -403,7 +404,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r
403#endif 404#endif
404 spin_lock(&c->erase_completion_lock); 405 spin_lock(&c->erase_completion_lock);
405 406
406 jffs2_link_node_ref(c, jeb, new, len); 407 jffs2_link_node_ref(c, jeb, new, len, ic);
407 408
408 if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { 409 if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) {
409 /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ 410 /* If it lives on the dirty_list, jffs2_reserve_space will put it there */
@@ -660,6 +661,10 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
660 spin_lock(&c->erase_completion_lock); 661 spin_lock(&c->erase_completion_lock);
661 662
662 ic = jffs2_raw_ref_to_ic(ref); 663 ic = jffs2_raw_ref_to_ic(ref);
664 /* It seems we should never call jffs2_mark_node_obsolete() for
665 XATTR nodes.... yet. Make sure we notice if/when we change
666 that :) */
667 BUG_ON(ic->class != RAWNODE_CLASS_INODE_CACHE);
663 for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino)) 668 for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino))
664 ; 669 ;
665 670
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index d2ad2a2081d8..743c9e52152d 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -92,11 +92,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
92#define jffs2_flash_writev(a,b,c,d,e,f) jffs2_flash_direct_writev(a,b,c,d,e) 92#define jffs2_flash_writev(a,b,c,d,e,f) jffs2_flash_direct_writev(a,b,c,d,e)
93#define jffs2_wbuf_timeout NULL 93#define jffs2_wbuf_timeout NULL
94#define jffs2_wbuf_process NULL 94#define jffs2_wbuf_process NULL
95#define jffs2_nor_ecc(c) (0)
96#define jffs2_dataflash(c) (0) 95#define jffs2_dataflash(c) (0)
97#define jffs2_nor_wbuf_flash(c) (0)
98#define jffs2_nor_ecc_flash_setup(c) (0)
99#define jffs2_nor_ecc_flash_cleanup(c) do {} while (0)
100#define jffs2_dataflash_setup(c) (0) 96#define jffs2_dataflash_setup(c) (0)
101#define jffs2_dataflash_cleanup(c) do {} while (0) 97#define jffs2_dataflash_cleanup(c) do {} while (0)
102#define jffs2_nor_wbuf_flash_setup(c) (0) 98#define jffs2_nor_wbuf_flash_setup(c) (0)
@@ -109,9 +105,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
109#ifdef CONFIG_JFFS2_SUMMARY 105#ifdef CONFIG_JFFS2_SUMMARY
110#define jffs2_can_mark_obsolete(c) (0) 106#define jffs2_can_mark_obsolete(c) (0)
111#else 107#else
112#define jffs2_can_mark_obsolete(c) \ 108#define jffs2_can_mark_obsolete(c) (c->mtd->flags & (MTD_BIT_WRITEABLE))
113 ((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & (MTD_ECC|MTD_PROGRAM_REGIONS))) || \
114 c->mtd->type == MTD_RAM)
115#endif 109#endif
116 110
117#define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH) 111#define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH)
@@ -135,15 +129,11 @@ int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c);
135int jffs2_nand_flash_setup(struct jffs2_sb_info *c); 129int jffs2_nand_flash_setup(struct jffs2_sb_info *c);
136void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c); 130void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c);
137 131
138#define jffs2_nor_ecc(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_ECC))
139int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c);
140void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c);
141
142#define jffs2_dataflash(c) (c->mtd->type == MTD_DATAFLASH) 132#define jffs2_dataflash(c) (c->mtd->type == MTD_DATAFLASH)
143int jffs2_dataflash_setup(struct jffs2_sb_info *c); 133int jffs2_dataflash_setup(struct jffs2_sb_info *c);
144void jffs2_dataflash_cleanup(struct jffs2_sb_info *c); 134void jffs2_dataflash_cleanup(struct jffs2_sb_info *c);
145 135
146#define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_PROGRAM_REGIONS)) 136#define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && ! (c->mtd->flags & MTD_BIT_WRITEABLE))
147int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c); 137int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c);
148void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c); 138void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c);
149 139
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index cffafec01e48..6fce703c0543 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -361,9 +361,9 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
361 xd->node = raw; 361 xd->node = raw;
362 362
363 raw->flash_offset = ofs | REF_PRISTINE; 363 raw->flash_offset = ofs | REF_PRISTINE;
364 raw->next_in_ino = (void *)xd;
365 364
366 jffs2_link_node_ref(c, jeb, raw, totlen); 365 jffs2_link_node_ref(c, jeb, raw, totlen, NULL);
366 /* FIXME */ raw->next_in_ino = (void *)xd;
367 367
368 if (jffs2_sum_active()) 368 if (jffs2_sum_active())
369 jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); 369 jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset);
@@ -425,9 +425,9 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
425 c->xref_temp = ref; 425 c->xref_temp = ref;
426 426
427 raw->flash_offset = ofs | REF_PRISTINE; 427 raw->flash_offset = ofs | REF_PRISTINE;
428 raw->next_in_ino = (void *)ref;
429 428
430 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rr->totlen))); 429 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rr->totlen)), NULL);
430 /* FIXME */ raw->next_in_ino = (void *)ref;
431 431
432 if (jffs2_sum_active()) 432 if (jffs2_sum_active())
433 jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset); 433 jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset);
@@ -844,10 +844,9 @@ scan_more:
844 printk(KERN_NOTICE "Failed to allocate node ref for clean marker\n"); 844 printk(KERN_NOTICE "Failed to allocate node ref for clean marker\n");
845 return -ENOMEM; 845 return -ENOMEM;
846 } 846 }
847 marker_ref->next_in_ino = NULL;
848 marker_ref->flash_offset = ofs | REF_NORMAL; 847 marker_ref->flash_offset = ofs | REF_NORMAL;
849 848
850 jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size); 849 jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size, NULL);
851 850
852 ofs += PAD(c->cleanmarker_size); 851 ofs += PAD(c->cleanmarker_size);
853 } 852 }
@@ -892,8 +891,7 @@ scan_more:
892 if (!ref) 891 if (!ref)
893 return -ENOMEM; 892 return -ENOMEM;
894 ref->flash_offset = ofs | REF_PRISTINE; 893 ref->flash_offset = ofs | REF_PRISTINE;
895 ref->next_in_ino = 0; 894 jffs2_link_node_ref(c, jeb, ref, PAD(je32_to_cpu(node->totlen)), NULL);
896 jffs2_link_node_ref(c, jeb, ref, PAD(je32_to_cpu(node->totlen)));
897 895
898 /* We can't summarise nodes we don't grok */ 896 /* We can't summarise nodes we don't grok */
899 jffs2_sum_disable_collecting(s); 897 jffs2_sum_disable_collecting(s);
@@ -1004,10 +1002,7 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
1004 1002
1005 raw->flash_offset = ofs | REF_UNCHECKED; 1003 raw->flash_offset = ofs | REF_UNCHECKED;
1006 1004
1007 raw->next_in_ino = ic->nodes; 1005 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(ri->totlen)), ic);
1008 ic->nodes = raw;
1009
1010 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(ri->totlen)));
1011 1006
1012 D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", 1007 D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n",
1013 je32_to_cpu(ri->ino), je32_to_cpu(ri->version), 1008 je32_to_cpu(ri->ino), je32_to_cpu(ri->version),
@@ -1082,10 +1077,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
1082 } 1077 }
1083 1078
1084 raw->flash_offset = ofs | REF_PRISTINE; 1079 raw->flash_offset = ofs | REF_PRISTINE;
1085 raw->next_in_ino = ic->nodes; 1080 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rd->totlen)), ic);
1086 ic->nodes = raw;
1087
1088 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rd->totlen)));
1089 1081
1090 fd->raw = raw; 1082 fd->raw = raw;
1091 fd->next = NULL; 1083 fd->next = NULL;
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index 1451732e1fa7..351ba9f8185e 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -430,10 +430,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
430 430
431 raw->flash_offset |= REF_UNCHECKED; 431 raw->flash_offset |= REF_UNCHECKED;
432 432
433 raw->next_in_ino = ic->nodes; 433 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spi->totlen)), ic);
434 ic->nodes = raw;
435
436 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spi->totlen)));
437 434
438 *pseudo_random += je32_to_cpu(spi->version); 435 *pseudo_random += je32_to_cpu(spi->version);
439 436
@@ -473,10 +470,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
473 } 470 }
474 471
475 raw->flash_offset |= REF_PRISTINE; 472 raw->flash_offset |= REF_PRISTINE;
476 raw->next_in_ino = ic->nodes; 473 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spd->totlen)), ic);
477 ic->nodes = raw;
478
479 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spd->totlen)));
480 474
481 fd->raw = raw; 475 fd->raw = raw;
482 fd->next = NULL; 476 fd->next = NULL;
@@ -525,9 +519,9 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
525 xd->node = raw; 519 xd->node = raw;
526 520
527 raw->flash_offset |= REF_UNCHECKED; 521 raw->flash_offset |= REF_UNCHECKED;
528 raw->next_in_ino = (void *)xd;
529 522
530 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spx->totlen))); 523 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spx->totlen)), NULL);
524 /* FIXME */ raw->next_in_ino = (void *)xd;
531 525
532 *pseudo_random += je32_to_cpu(spx->xid); 526 *pseudo_random += je32_to_cpu(spx->xid);
533 sp += JFFS2_SUMMARY_XATTR_SIZE; 527 sp += JFFS2_SUMMARY_XATTR_SIZE;
@@ -561,9 +555,9 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
561 c->xref_temp = ref; 555 c->xref_temp = ref;
562 556
563 raw->flash_offset |= REF_UNCHECKED; 557 raw->flash_offset |= REF_UNCHECKED;
564 raw->next_in_ino = (void *)ref;
565 558
566 jffs2_link_node_ref(c, jeb, raw, PAD(sizeof(struct jffs2_raw_xref))); 559 jffs2_link_node_ref(c, jeb, raw, PAD(sizeof(struct jffs2_raw_xref)), NULL);
560 /* FIXME */ raw->next_in_ino = (void *)ref;
567 561
568 *pseudo_random += raw->flash_offset; 562 *pseudo_random += raw->flash_offset;
569 sp += JFFS2_SUMMARY_XREF_SIZE; 563 sp += JFFS2_SUMMARY_XREF_SIZE;
@@ -664,9 +658,8 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
664 } 658 }
665 659
666 marker_ref->flash_offset = jeb->offset | REF_NORMAL; 660 marker_ref->flash_offset = jeb->offset | REF_NORMAL;
667 marker_ref->next_in_ino = NULL;
668 661
669 jffs2_link_node_ref(c, jeb, marker_ref, je32_to_cpu(summary->cln_mkr)); 662 jffs2_link_node_ref(c, jeb, marker_ref, je32_to_cpu(summary->cln_mkr), NULL);
670 } 663 }
671 } 664 }
672 665
@@ -686,10 +679,9 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
686 return -ENOMEM; 679 return -ENOMEM;
687 } 680 }
688 681
689 cache_ref->next_in_ino = NULL;
690 cache_ref->flash_offset |= REF_NORMAL; 682 cache_ref->flash_offset |= REF_NORMAL;
691 683
692 jffs2_link_node_ref(c, jeb, cache_ref, sumsize); 684 jffs2_link_node_ref(c, jeb, cache_ref, sumsize, NULL);
693 685
694 if (unlikely(jeb->free_size)) { 686 if (unlikely(jeb->free_size)) {
695 JFFS2_WARNING("Free size 0x%x bytes in eraseblock @0x%08x with summary?\n", 687 JFFS2_WARNING("Free size 0x%x bytes in eraseblock @0x%08x with summary?\n",
@@ -849,9 +841,8 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
849 841
850 ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size; 842 ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size;
851 ref->flash_offset |= REF_OBSOLETE; 843 ref->flash_offset |= REF_OBSOLETE;
852 ref->next_in_ino = 0;
853 844
854 jffs2_link_node_ref(c, jeb, ref, c->sector_size - jeb->free_size); 845 jffs2_link_node_ref(c, jeb, ref, c->sector_size - jeb->free_size, NULL);
855 } 846 }
856 847
857 c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; 848 c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
@@ -909,11 +900,10 @@ int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
909 return -ENOMEM; 900 return -ENOMEM;
910 } 901 }
911 902
912 summary_ref->next_in_ino = NULL;
913 summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL; 903 summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL;
914 904
915 spin_lock(&c->erase_completion_lock); 905 spin_lock(&c->erase_completion_lock);
916 jffs2_link_node_ref(c, jeb, summary_ref, infosize); 906 jffs2_link_node_ref(c, jeb, summary_ref, infosize, NULL);
917 907
918 return 0; 908 return 0;
919} 909}
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 0442a5753d33..916c87d3393b 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -265,12 +265,14 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
265 265
266 266
267 /* ... and get an allocation of space from a shiny new block instead */ 267 /* ... and get an allocation of space from a shiny new block instead */
268 ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len, JFFS2_SUMMARY_NOSUM_SIZE); 268 ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE);
269 if (ret) { 269 if (ret) {
270 printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); 270 printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n");
271 kfree(buf); 271 kfree(buf);
272 return; 272 return;
273 } 273 }
274 ofs = write_ofs(c);
275
274 if (end-start >= c->wbuf_pagesize) { 276 if (end-start >= c->wbuf_pagesize) {
275 /* Need to do another write immediately, but it's possible 277 /* Need to do another write immediately, but it's possible
276 that this is just because the wbuf itself is completely 278 that this is just because the wbuf itself is completely
@@ -312,9 +314,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
312 return; 314 return;
313 315
314 raw2->flash_offset = ofs | REF_OBSOLETE; 316 raw2->flash_offset = ofs | REF_OBSOLETE;
315 raw2->next_in_ino = NULL;
316 317
317 jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw)); 318 jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw), NULL);
318 } 319 }
319 return; 320 return;
320 } 321 }
@@ -507,11 +508,10 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
507 return -ENOMEM; 508 return -ENOMEM;
508 ref->flash_offset = c->wbuf_ofs + c->wbuf_len; 509 ref->flash_offset = c->wbuf_ofs + c->wbuf_len;
509 ref->flash_offset |= REF_OBSOLETE; 510 ref->flash_offset |= REF_OBSOLETE;
510 ref->next_in_ino = NULL;
511 511
512 spin_lock(&c->erase_completion_lock); 512 spin_lock(&c->erase_completion_lock);
513 513
514 jffs2_link_node_ref(c, jeb, ref, waste); 514 jffs2_link_node_ref(c, jeb, ref, waste, NULL);
515 /* FIXME: that made it count as dirty. Convert to wasted */ 515 /* FIXME: that made it count as dirty. Convert to wasted */
516 jeb->dirty_size -= waste; 516 jeb->dirty_size -= waste;
517 c->dirty_size -= waste; 517 c->dirty_size -= waste;
@@ -650,19 +650,6 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
650 } 650 }
651 651
652 /* 652 /*
653 * Fixup the wbuf if we are moving to a new eraseblock. The
654 * checks below fail for ECC'd NOR because cleanmarker == 16,
655 * so a block starts at xxx0010.
656 */
657 if (jffs2_nor_ecc(c)) {
658 if (((c->wbuf_ofs % c->sector_size) == 0) && !c->wbuf_len) {
659 c->wbuf_ofs = PAGE_DIV(to);
660 c->wbuf_len = PAGE_MOD(to);
661 memset(c->wbuf,0xff,c->wbuf_pagesize);
662 }
663 }
664
665 /*
666 * Sanity checks on target address. It's permitted to write 653 * Sanity checks on target address. It's permitted to write
667 * at PAD(c->wbuf_len+c->wbuf_ofs), and it's permitted to 654 * at PAD(c->wbuf_len+c->wbuf_ofs), and it's permitted to
668 * write at the beginning of a new erase block. Anything else, 655 * write at the beginning of a new erase block. Anything else,
@@ -1107,7 +1094,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
1107 1094
1108 /* Initialise write buffer */ 1095 /* Initialise write buffer */
1109 init_rwsem(&c->wbuf_sem); 1096 init_rwsem(&c->wbuf_sem);
1110 c->wbuf_pagesize = c->mtd->oobblock; 1097 c->wbuf_pagesize = c->mtd->writesize;
1111 c->wbuf_ofs = 0xFFFFFFFF; 1098 c->wbuf_ofs = 0xFFFFFFFF;
1112 1099
1113 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); 1100 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
@@ -1178,33 +1165,14 @@ void jffs2_dataflash_cleanup(struct jffs2_sb_info *c) {
1178 kfree(c->wbuf); 1165 kfree(c->wbuf);
1179} 1166}
1180 1167
1181int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c) {
1182 /* Cleanmarker is actually larger on the flashes */
1183 c->cleanmarker_size = 16;
1184
1185 /* Initialize write buffer */
1186 init_rwsem(&c->wbuf_sem);
1187 c->wbuf_pagesize = c->mtd->eccsize;
1188 c->wbuf_ofs = 0xFFFFFFFF;
1189
1190 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
1191 if (!c->wbuf)
1192 return -ENOMEM;
1193
1194 return 0;
1195}
1196
1197void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) {
1198 kfree(c->wbuf);
1199}
1200
1201int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) { 1168int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) {
1202 /* Cleanmarker currently occupies a whole programming region */ 1169 /* Cleanmarker currently occupies whole programming regions,
1203 c->cleanmarker_size = MTD_PROGREGION_SIZE(c->mtd); 1170 * either one or 2 for 8Byte STMicro flashes. */
1171 c->cleanmarker_size = max(16u, c->mtd->writesize);
1204 1172
1205 /* Initialize write buffer */ 1173 /* Initialize write buffer */
1206 init_rwsem(&c->wbuf_sem); 1174 init_rwsem(&c->wbuf_sem);
1207 c->wbuf_pagesize = MTD_PROGREGION_SIZE(c->mtd); 1175 c->wbuf_pagesize = c->mtd->writesize;
1208 c->wbuf_ofs = 0xFFFFFFFF; 1176 c->wbuf_ofs = 0xFFFFFFFF;
1209 1177
1210 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); 1178 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c
index 4462541d11f8..0e12b7561b71 100644
--- a/fs/jffs2/write.c
+++ b/fs/jffs2/write.c
@@ -56,12 +56,15 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint
56/* jffs2_write_dnode - given a raw_inode, allocate a full_dnode for it, 56/* jffs2_write_dnode - given a raw_inode, allocate a full_dnode for it,
57 write it to the flash, link it into the existing inode/fragment list */ 57 write it to the flash, link it into the existing inode/fragment list */
58 58
59struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode) 59struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
60 struct jffs2_raw_inode *ri, const unsigned char *data,
61 uint32_t datalen, int alloc_mode)
60 62
61{ 63{
62 struct jffs2_raw_node_ref *raw; 64 struct jffs2_raw_node_ref *raw;
63 struct jffs2_full_dnode *fn; 65 struct jffs2_full_dnode *fn;
64 size_t retlen; 66 size_t retlen;
67 uint32_t flash_ofs;
65 struct kvec vecs[2]; 68 struct kvec vecs[2];
66 int ret; 69 int ret;
67 int retried = 0; 70 int retried = 0;
@@ -77,8 +80,6 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
77 vecs[1].iov_base = (unsigned char *)data; 80 vecs[1].iov_base = (unsigned char *)data;
78 vecs[1].iov_len = datalen; 81 vecs[1].iov_len = datalen;
79 82
80 jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len);
81
82 if (je32_to_cpu(ri->totlen) != sizeof(*ri) + datalen) { 83 if (je32_to_cpu(ri->totlen) != sizeof(*ri) + datalen) {
83 printk(KERN_WARNING "jffs2_write_dnode: ri->totlen (0x%08x) != sizeof(*ri) (0x%08zx) + datalen (0x%08x)\n", je32_to_cpu(ri->totlen), sizeof(*ri), datalen); 84 printk(KERN_WARNING "jffs2_write_dnode: ri->totlen (0x%08x) != sizeof(*ri) (0x%08zx) + datalen (0x%08x)\n", je32_to_cpu(ri->totlen), sizeof(*ri), datalen);
84 } 85 }
@@ -102,7 +103,9 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
102 retry: 103 retry:
103 fn->raw = raw; 104 fn->raw = raw;
104 105
105 raw->flash_offset = flash_ofs; 106 raw->flash_offset = flash_ofs = write_ofs(c);
107
108 jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len);
106 109
107 if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { 110 if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) {
108 BUG_ON(!retried); 111 BUG_ON(!retried);
@@ -122,16 +125,13 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
122 125
123 /* Mark the space as dirtied */ 126 /* Mark the space as dirtied */
124 if (retlen) { 127 if (retlen) {
125 /* Doesn't belong to any inode */
126 raw->next_in_ino = NULL;
127
128 /* Don't change raw->size to match retlen. We may have 128 /* Don't change raw->size to match retlen. We may have
129 written the node header already, and only the data will 129 written the node header already, and only the data will
130 seem corrupted, in which case the scan would skip over 130 seem corrupted, in which case the scan would skip over
131 any node we write before the original intended end of 131 any node we write before the original intended end of
132 this node */ 132 this node */
133 raw->flash_offset |= REF_OBSOLETE; 133 raw->flash_offset |= REF_OBSOLETE;
134 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen)); 134 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen), NULL);
135 jffs2_mark_node_obsolete(c, raw); 135 jffs2_mark_node_obsolete(c, raw);
136 } else { 136 } else {
137 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset); 137 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset);
@@ -150,19 +150,20 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
150 jffs2_dbg_acct_paranoia_check(c, jeb); 150 jffs2_dbg_acct_paranoia_check(c, jeb);
151 151
152 if (alloc_mode == ALLOC_GC) { 152 if (alloc_mode == ALLOC_GC) {
153 ret = jffs2_reserve_space_gc(c, sizeof(*ri) + datalen, &flash_ofs, 153 ret = jffs2_reserve_space_gc(c, sizeof(*ri) + datalen, &dummy,
154 &dummy, JFFS2_SUMMARY_INODE_SIZE); 154 JFFS2_SUMMARY_INODE_SIZE);
155 } else { 155 } else {
156 /* Locking pain */ 156 /* Locking pain */
157 up(&f->sem); 157 up(&f->sem);
158 jffs2_complete_reservation(c); 158 jffs2_complete_reservation(c);
159 159
160 ret = jffs2_reserve_space(c, sizeof(*ri) + datalen, &flash_ofs, 160 ret = jffs2_reserve_space(c, sizeof(*ri) + datalen, &dummy,
161 &dummy, alloc_mode, JFFS2_SUMMARY_INODE_SIZE); 161 alloc_mode, JFFS2_SUMMARY_INODE_SIZE);
162 down(&f->sem); 162 down(&f->sem);
163 } 163 }
164 164
165 if (!ret) { 165 if (!ret) {
166 flash_ofs = write_ofs(c);
166 D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); 167 D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs));
167 168
168 jffs2_dbg_acct_sanity_check(c,jeb); 169 jffs2_dbg_acct_sanity_check(c,jeb);
@@ -189,13 +190,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
189 } else { 190 } else {
190 raw->flash_offset |= REF_NORMAL; 191 raw->flash_offset |= REF_NORMAL;
191 } 192 }
192 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen)); 193 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen), f->inocache);
193
194 /* Link into per-inode list */
195 spin_lock(&c->erase_completion_lock);
196 raw->next_in_ino = f->inocache->nodes;
197 f->inocache->nodes = raw;
198 spin_unlock(&c->erase_completion_lock);
199 194
200 D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", 195 D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n",
201 flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize), 196 flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize),
@@ -209,12 +204,15 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
209 return fn; 204 return fn;
210} 205}
211 206
212struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs, int alloc_mode) 207struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
208 struct jffs2_raw_dirent *rd, const unsigned char *name,
209 uint32_t namelen, int alloc_mode)
213{ 210{
214 struct jffs2_raw_node_ref *raw; 211 struct jffs2_raw_node_ref *raw;
215 struct jffs2_full_dirent *fd; 212 struct jffs2_full_dirent *fd;
216 size_t retlen; 213 size_t retlen;
217 struct kvec vecs[2]; 214 struct kvec vecs[2];
215 uint32_t flash_ofs = write_ofs(c);
218 int retried = 0; 216 int retried = 0;
219 int ret; 217 int ret;
220 218
@@ -275,9 +273,8 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
275 sizeof(*rd)+namelen, flash_ofs, ret, retlen); 273 sizeof(*rd)+namelen, flash_ofs, ret, retlen);
276 /* Mark the space as dirtied */ 274 /* Mark the space as dirtied */
277 if (retlen) { 275 if (retlen) {
278 raw->next_in_ino = NULL;
279 raw->flash_offset |= REF_OBSOLETE; 276 raw->flash_offset |= REF_OBSOLETE;
280 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen)); 277 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen), NULL);
281 jffs2_mark_node_obsolete(c, raw); 278 jffs2_mark_node_obsolete(c, raw);
282 } else { 279 } else {
283 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset); 280 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset);
@@ -296,19 +293,20 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
296 jffs2_dbg_acct_paranoia_check(c, jeb); 293 jffs2_dbg_acct_paranoia_check(c, jeb);
297 294
298 if (alloc_mode == ALLOC_GC) { 295 if (alloc_mode == ALLOC_GC) {
299 ret = jffs2_reserve_space_gc(c, sizeof(*rd) + namelen, &flash_ofs, 296 ret = jffs2_reserve_space_gc(c, sizeof(*rd) + namelen, &dummy,
300 &dummy, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 297 JFFS2_SUMMARY_DIRENT_SIZE(namelen));
301 } else { 298 } else {
302 /* Locking pain */ 299 /* Locking pain */
303 up(&f->sem); 300 up(&f->sem);
304 jffs2_complete_reservation(c); 301 jffs2_complete_reservation(c);
305 302
306 ret = jffs2_reserve_space(c, sizeof(*rd) + namelen, &flash_ofs, 303 ret = jffs2_reserve_space(c, sizeof(*rd) + namelen, &dummy,
307 &dummy, alloc_mode, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 304 alloc_mode, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
308 down(&f->sem); 305 down(&f->sem);
309 } 306 }
310 307
311 if (!ret) { 308 if (!ret) {
309 flash_ofs = write_ofs(c);
312 D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); 310 D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs));
313 jffs2_dbg_acct_sanity_check(c,jeb); 311 jffs2_dbg_acct_sanity_check(c,jeb);
314 jffs2_dbg_acct_paranoia_check(c, jeb); 312 jffs2_dbg_acct_paranoia_check(c, jeb);
@@ -323,12 +321,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
323 } 321 }
324 /* Mark the space used */ 322 /* Mark the space used */
325 raw->flash_offset |= REF_PRISTINE; 323 raw->flash_offset |= REF_PRISTINE;
326 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen)); 324 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen), f->inocache);
327
328 spin_lock(&c->erase_completion_lock);
329 raw->next_in_ino = f->inocache->nodes;
330 f->inocache->nodes = raw;
331 spin_unlock(&c->erase_completion_lock);
332 325
333 if (retried) { 326 if (retried) {
334 jffs2_dbg_acct_sanity_check(c,NULL); 327 jffs2_dbg_acct_sanity_check(c,NULL);
@@ -354,14 +347,14 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
354 struct jffs2_full_dnode *fn; 347 struct jffs2_full_dnode *fn;
355 unsigned char *comprbuf = NULL; 348 unsigned char *comprbuf = NULL;
356 uint16_t comprtype = JFFS2_COMPR_NONE; 349 uint16_t comprtype = JFFS2_COMPR_NONE;
357 uint32_t phys_ofs, alloclen; 350 uint32_t alloclen;
358 uint32_t datalen, cdatalen; 351 uint32_t datalen, cdatalen;
359 int retried = 0; 352 int retried = 0;
360 353
361 retry: 354 retry:
362 D2(printk(KERN_DEBUG "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", writelen, offset)); 355 D2(printk(KERN_DEBUG "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", writelen, offset));
363 356
364 ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, &phys_ofs, 357 ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN,
365 &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); 358 &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
366 if (ret) { 359 if (ret) {
367 D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret)); 360 D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret));
@@ -389,7 +382,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
389 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); 382 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
390 ri->data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen)); 383 ri->data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen));
391 384
392 fn = jffs2_write_dnode(c, f, ri, comprbuf, cdatalen, phys_ofs, ALLOC_NORETRY); 385 fn = jffs2_write_dnode(c, f, ri, comprbuf, cdatalen, ALLOC_NORETRY);
393 386
394 jffs2_free_comprbuf(comprbuf, buf); 387 jffs2_free_comprbuf(comprbuf, buf);
395 388
@@ -443,13 +436,13 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str
443 struct jffs2_raw_dirent *rd; 436 struct jffs2_raw_dirent *rd;
444 struct jffs2_full_dnode *fn; 437 struct jffs2_full_dnode *fn;
445 struct jffs2_full_dirent *fd; 438 struct jffs2_full_dirent *fd;
446 uint32_t alloclen, phys_ofs; 439 uint32_t alloclen;
447 int ret; 440 int ret;
448 441
449 /* Try to reserve enough space for both node and dirent. 442 /* Try to reserve enough space for both node and dirent.
450 * Just the node will do for now, though 443 * Just the node will do for now, though
451 */ 444 */
452 ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL, 445 ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL,
453 JFFS2_SUMMARY_INODE_SIZE); 446 JFFS2_SUMMARY_INODE_SIZE);
454 D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); 447 D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen));
455 if (ret) { 448 if (ret) {
@@ -460,7 +453,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str
460 ri->data_crc = cpu_to_je32(0); 453 ri->data_crc = cpu_to_je32(0);
461 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); 454 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
462 455
463 fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, ALLOC_NORMAL); 456 fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL);
464 457
465 D1(printk(KERN_DEBUG "jffs2_do_create created file with mode 0x%x\n", 458 D1(printk(KERN_DEBUG "jffs2_do_create created file with mode 0x%x\n",
466 jemode_to_cpu(ri->mode))); 459 jemode_to_cpu(ri->mode)));
@@ -479,7 +472,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str
479 472
480 up(&f->sem); 473 up(&f->sem);
481 jffs2_complete_reservation(c); 474 jffs2_complete_reservation(c);
482 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, 475 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
483 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 476 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
484 477
485 if (ret) { 478 if (ret) {
@@ -511,7 +504,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str
511 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); 504 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
512 rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); 505 rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
513 506
514 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL); 507 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, ALLOC_NORMAL);
515 508
516 jffs2_free_raw_dirent(rd); 509 jffs2_free_raw_dirent(rd);
517 510
@@ -540,7 +533,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
540{ 533{
541 struct jffs2_raw_dirent *rd; 534 struct jffs2_raw_dirent *rd;
542 struct jffs2_full_dirent *fd; 535 struct jffs2_full_dirent *fd;
543 uint32_t alloclen, phys_ofs; 536 uint32_t alloclen;
544 int ret; 537 int ret;
545 538
546 if (1 /* alternative branch needs testing */ || 539 if (1 /* alternative branch needs testing */ ||
@@ -551,7 +544,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
551 if (!rd) 544 if (!rd)
552 return -ENOMEM; 545 return -ENOMEM;
553 546
554 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, 547 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
555 ALLOC_DELETION, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 548 ALLOC_DELETION, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
556 if (ret) { 549 if (ret) {
557 jffs2_free_raw_dirent(rd); 550 jffs2_free_raw_dirent(rd);
@@ -575,7 +568,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
575 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); 568 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
576 rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); 569 rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
577 570
578 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_DELETION); 571 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, ALLOC_DELETION);
579 572
580 jffs2_free_raw_dirent(rd); 573 jffs2_free_raw_dirent(rd);
581 574
@@ -654,14 +647,14 @@ int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint
654{ 647{
655 struct jffs2_raw_dirent *rd; 648 struct jffs2_raw_dirent *rd;
656 struct jffs2_full_dirent *fd; 649 struct jffs2_full_dirent *fd;
657 uint32_t alloclen, phys_ofs; 650 uint32_t alloclen;
658 int ret; 651 int ret;
659 652
660 rd = jffs2_alloc_raw_dirent(); 653 rd = jffs2_alloc_raw_dirent();
661 if (!rd) 654 if (!rd)
662 return -ENOMEM; 655 return -ENOMEM;
663 656
664 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, 657 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
665 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 658 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
666 if (ret) { 659 if (ret) {
667 jffs2_free_raw_dirent(rd); 660 jffs2_free_raw_dirent(rd);
@@ -687,7 +680,7 @@ int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint
687 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); 680 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
688 rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); 681 rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
689 682
690 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL); 683 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, ALLOC_NORMAL);
691 684
692 jffs2_free_raw_dirent(rd); 685 jffs2_free_raw_dirent(rd);
693 686
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index e16f8460ff04..008f91b1c171 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -49,9 +49,9 @@
49 * is used to be as a wrapper of do_verify_xattr_datum() and do_load_xattr_datum(). 49 * is used to be as a wrapper of do_verify_xattr_datum() and do_load_xattr_datum().
50 * If xd need to call do_verify_xattr_datum() at first, it's called before calling 50 * If xd need to call do_verify_xattr_datum() at first, it's called before calling
51 * do_load_xattr_datum(). The meanings of return value is same as do_verify_xattr_datum(). 51 * do_load_xattr_datum(). The meanings of return value is same as do_verify_xattr_datum().
52 * save_xattr_datum(c, xd, phys_ofs) 52 * save_xattr_datum(c, xd)
53 * is used to write xdatum to medium. xd->version will be incremented. 53 * is used to write xdatum to medium. xd->version will be incremented.
54 * create_xattr_datum(c, xprefix, xname, xvalue, xsize, phys_ofs) 54 * create_xattr_datum(c, xprefix, xname, xvalue, xsize)
55 * is used to create new xdatum and write to medium. 55 * is used to create new xdatum and write to medium.
56 * -------------------------------------------------- */ 56 * -------------------------------------------------- */
57 57
@@ -301,7 +301,7 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
301 return rc; 301 return rc;
302} 302}
303 303
304static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd, uint32_t phys_ofs) 304static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
305{ 305{
306 /* must be called under down_write(xattr_sem) */ 306 /* must be called under down_write(xattr_sem) */
307 struct jffs2_raw_xattr rx; 307 struct jffs2_raw_xattr rx;
@@ -309,6 +309,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
309 struct kvec vecs[2]; 309 struct kvec vecs[2];
310 uint32_t length; 310 uint32_t length;
311 int rc, totlen; 311 int rc, totlen;
312 uint32_t phys_ofs = write_ofs(c);
312 313
313 BUG_ON(!xd->xname); 314 BUG_ON(!xd->xname);
314 315
@@ -322,7 +323,6 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
322 if (!raw) 323 if (!raw)
323 return -ENOMEM; 324 return -ENOMEM;
324 raw->flash_offset = phys_ofs; 325 raw->flash_offset = phys_ofs;
325 raw->next_in_ino = (void *)xd;
326 326
327 /* Setup raw-xattr */ 327 /* Setup raw-xattr */
328 rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 328 rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -345,8 +345,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
345 rc = rc ? rc : -EIO; 345 rc = rc ? rc : -EIO;
346 if (length) { 346 if (length) {
347 raw->flash_offset |= REF_OBSOLETE; 347 raw->flash_offset |= REF_OBSOLETE;
348 raw->next_in_ino = NULL; 348 jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
349 jffs2_add_physical_node_ref(c, raw, PAD(totlen));
350 jffs2_mark_node_obsolete(c, raw); 349 jffs2_mark_node_obsolete(c, raw);
351 } else { 350 } else {
352 jffs2_free_raw_node_ref(raw); 351 jffs2_free_raw_node_ref(raw);
@@ -356,7 +355,9 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
356 355
357 /* success */ 356 /* success */
358 raw->flash_offset |= REF_PRISTINE; 357 raw->flash_offset |= REF_PRISTINE;
359 jffs2_add_physical_node_ref(c, raw, PAD(totlen)); 358 jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
359 /* FIXME */ raw->next_in_ino = (void *)xd;
360
360 if (xd->node) 361 if (xd->node)
361 delete_xattr_datum_node(c, xd); 362 delete_xattr_datum_node(c, xd);
362 xd->node = raw; 363 xd->node = raw;
@@ -369,8 +370,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
369 370
370static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c, 371static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
371 int xprefix, const char *xname, 372 int xprefix, const char *xname,
372 const char *xvalue, int xsize, 373 const char *xvalue, int xsize)
373 uint32_t phys_ofs)
374{ 374{
375 /* must be called under down_write(xattr_sem) */ 375 /* must be called under down_write(xattr_sem) */
376 struct jffs2_xattr_datum *xd; 376 struct jffs2_xattr_datum *xd;
@@ -419,7 +419,7 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
419 xd->value_len = xsize; 419 xd->value_len = xsize;
420 xd->data_crc = crc32(0, data, xd->name_len + 1 + xd->value_len); 420 xd->data_crc = crc32(0, data, xd->name_len + 1 + xd->value_len);
421 421
422 rc = save_xattr_datum(c, xd, phys_ofs); 422 rc = save_xattr_datum(c, xd);
423 if (rc) { 423 if (rc) {
424 kfree(xd->xname); 424 kfree(xd->xname);
425 jffs2_free_xattr_datum(xd); 425 jffs2_free_xattr_datum(xd);
@@ -446,9 +446,9 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
446 * delete_xattr_ref(c, ref) 446 * delete_xattr_ref(c, ref)
447 * is used to delete jffs2_xattr_ref object. If the reference counter of xdatum 447 * is used to delete jffs2_xattr_ref object. If the reference counter of xdatum
448 * is refered by this xref become 0, delete_xattr_datum() is called later. 448 * is refered by this xref become 0, delete_xattr_datum() is called later.
449 * save_xattr_ref(c, ref, phys_ofs) 449 * save_xattr_ref(c, ref)
450 * is used to write xref to medium. 450 * is used to write xref to medium.
451 * create_xattr_ref(c, ic, xd, phys_ofs) 451 * create_xattr_ref(c, ic, xd)
452 * is used to create a new xref and write to medium. 452 * is used to create a new xref and write to medium.
453 * jffs2_xattr_delete_inode(c, ic) 453 * jffs2_xattr_delete_inode(c, ic)
454 * is called to remove xrefs related to obsolete inode when inode is unlinked. 454 * is called to remove xrefs related to obsolete inode when inode is unlinked.
@@ -554,19 +554,19 @@ static void delete_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *re
554 jffs2_free_xattr_ref(ref); 554 jffs2_free_xattr_ref(ref);
555} 555}
556 556
557static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, uint32_t phys_ofs) 557static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
558{ 558{
559 /* must be called under down_write(xattr_sem) */ 559 /* must be called under down_write(xattr_sem) */
560 struct jffs2_raw_node_ref *raw; 560 struct jffs2_raw_node_ref *raw;
561 struct jffs2_raw_xref rr; 561 struct jffs2_raw_xref rr;
562 uint32_t length; 562 uint32_t length;
563 uint32_t phys_ofs = write_ofs(c);
563 int ret; 564 int ret;
564 565
565 raw = jffs2_alloc_raw_node_ref(); 566 raw = jffs2_alloc_raw_node_ref();
566 if (!raw) 567 if (!raw)
567 return -ENOMEM; 568 return -ENOMEM;
568 raw->flash_offset = phys_ofs; 569 raw->flash_offset = phys_ofs;
569 raw->next_in_ino = (void *)ref;
570 570
571 rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 571 rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
572 rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF); 572 rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF);
@@ -584,8 +584,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
584 ret = ret ? ret : -EIO; 584 ret = ret ? ret : -EIO;
585 if (length) { 585 if (length) {
586 raw->flash_offset |= REF_OBSOLETE; 586 raw->flash_offset |= REF_OBSOLETE;
587 raw->next_in_ino = NULL; 587 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
588 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)));
589 jffs2_mark_node_obsolete(c, raw); 588 jffs2_mark_node_obsolete(c, raw);
590 } else { 589 } else {
591 jffs2_free_raw_node_ref(raw); 590 jffs2_free_raw_node_ref(raw);
@@ -594,7 +593,8 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
594 } 593 }
595 raw->flash_offset |= REF_PRISTINE; 594 raw->flash_offset |= REF_PRISTINE;
596 595
597 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr))); 596 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
597 /* FIXME */ raw->next_in_ino = (void *)ref;
598 if (ref->node) 598 if (ref->node)
599 delete_xattr_ref_node(c, ref); 599 delete_xattr_ref_node(c, ref);
600 ref->node = raw; 600 ref->node = raw;
@@ -605,7 +605,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
605} 605}
606 606
607static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, 607static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic,
608 struct jffs2_xattr_datum *xd, uint32_t phys_ofs) 608 struct jffs2_xattr_datum *xd)
609{ 609{
610 /* must be called under down_write(xattr_sem) */ 610 /* must be called under down_write(xattr_sem) */
611 struct jffs2_xattr_ref *ref; 611 struct jffs2_xattr_ref *ref;
@@ -617,7 +617,7 @@ static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct
617 ref->ic = ic; 617 ref->ic = ic;
618 ref->xd = xd; 618 ref->xd = xd;
619 619
620 ret = save_xattr_ref(c, ref, phys_ofs); 620 ret = save_xattr_ref(c, ref);
621 if (ret) { 621 if (ret) {
622 jffs2_free_xattr_ref(ref); 622 jffs2_free_xattr_ref(ref);
623 return ERR_PTR(ret); 623 return ERR_PTR(ret);
@@ -1063,7 +1063,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1063 struct jffs2_inode_cache *ic = f->inocache; 1063 struct jffs2_inode_cache *ic = f->inocache;
1064 struct jffs2_xattr_datum *xd; 1064 struct jffs2_xattr_datum *xd;
1065 struct jffs2_xattr_ref *ref, *newref, **pref; 1065 struct jffs2_xattr_ref *ref, *newref, **pref;
1066 uint32_t phys_ofs, length, request; 1066 uint32_t length, request;
1067 int rc; 1067 int rc;
1068 1068
1069 rc = check_xattr_ref_inode(c, ic); 1069 rc = check_xattr_ref_inode(c, ic);
@@ -1071,7 +1071,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1071 return rc; 1071 return rc;
1072 1072
1073 request = PAD(sizeof(struct jffs2_raw_xattr) + strlen(xname) + 1 + size); 1073 request = PAD(sizeof(struct jffs2_raw_xattr) + strlen(xname) + 1 + size);
1074 rc = jffs2_reserve_space(c, request, &phys_ofs, &length, 1074 rc = jffs2_reserve_space(c, request, &length,
1075 ALLOC_NORMAL, JFFS2_SUMMARY_XATTR_SIZE); 1075 ALLOC_NORMAL, JFFS2_SUMMARY_XATTR_SIZE);
1076 if (rc) { 1076 if (rc) {
1077 JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request); 1077 JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request);
@@ -1118,7 +1118,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1118 goto out; 1118 goto out;
1119 } 1119 }
1120 found: 1120 found:
1121 xd = create_xattr_datum(c, xprefix, xname, buffer, size, phys_ofs); 1121 xd = create_xattr_datum(c, xprefix, xname, buffer, size);
1122 if (IS_ERR(xd)) { 1122 if (IS_ERR(xd)) {
1123 rc = PTR_ERR(xd); 1123 rc = PTR_ERR(xd);
1124 goto out; 1124 goto out;
@@ -1128,7 +1128,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1128 1128
1129 /* create xattr_ref */ 1129 /* create xattr_ref */
1130 request = PAD(sizeof(struct jffs2_raw_xref)); 1130 request = PAD(sizeof(struct jffs2_raw_xref));
1131 rc = jffs2_reserve_space(c, request, &phys_ofs, &length, 1131 rc = jffs2_reserve_space(c, request, &length,
1132 ALLOC_NORMAL, JFFS2_SUMMARY_XREF_SIZE); 1132 ALLOC_NORMAL, JFFS2_SUMMARY_XREF_SIZE);
1133 if (rc) { 1133 if (rc) {
1134 JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request); 1134 JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request);
@@ -1142,7 +1142,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1142 down_write(&c->xattr_sem); 1142 down_write(&c->xattr_sem);
1143 if (ref) 1143 if (ref)
1144 *pref = ref->next; 1144 *pref = ref->next;
1145 newref = create_xattr_ref(c, ic, xd, phys_ofs); 1145 newref = create_xattr_ref(c, ic, xd);
1146 if (IS_ERR(newref)) { 1146 if (IS_ERR(newref)) {
1147 if (ref) { 1147 if (ref) {
1148 ref->next = ic->xref; 1148 ref->next = ic->xref;
@@ -1171,7 +1171,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
1171 * -------------------------------------------------- */ 1171 * -------------------------------------------------- */
1172int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) 1172int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
1173{ 1173{
1174 uint32_t phys_ofs, totlen, length, old_ofs; 1174 uint32_t totlen, length, old_ofs;
1175 int rc = -EINVAL; 1175 int rc = -EINVAL;
1176 1176
1177 down_write(&c->xattr_sem); 1177 down_write(&c->xattr_sem);
@@ -1191,13 +1191,13 @@ int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xatt
1191 } else if (unlikely(rc < 0)) 1191 } else if (unlikely(rc < 0))
1192 goto out; 1192 goto out;
1193 } 1193 }
1194 rc = jffs2_reserve_space_gc(c, totlen, &phys_ofs, &length, JFFS2_SUMMARY_XATTR_SIZE); 1194 rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XATTR_SIZE);
1195 if (rc || length < totlen) { 1195 if (rc || length < totlen) {
1196 JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, totlen); 1196 JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, totlen);
1197 rc = rc ? rc : -EBADFD; 1197 rc = rc ? rc : -EBADFD;
1198 goto out; 1198 goto out;
1199 } 1199 }
1200 rc = save_xattr_datum(c, xd, phys_ofs); 1200 rc = save_xattr_datum(c, xd);
1201 if (!rc) 1201 if (!rc)
1202 dbg_xattr("xdatum (xid=%u, version=%u) GC'ed from %#08x to %08x\n", 1202 dbg_xattr("xdatum (xid=%u, version=%u) GC'ed from %#08x to %08x\n",
1203 xd->xid, xd->version, old_ofs, ref_offset(xd->node)); 1203 xd->xid, xd->version, old_ofs, ref_offset(xd->node));
@@ -1209,7 +1209,7 @@ int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xatt
1209 1209
1210int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) 1210int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
1211{ 1211{
1212 uint32_t phys_ofs, totlen, length, old_ofs; 1212 uint32_t totlen, length, old_ofs;
1213 int rc = -EINVAL; 1213 int rc = -EINVAL;
1214 1214
1215 down_write(&c->xattr_sem); 1215 down_write(&c->xattr_sem);
@@ -1220,14 +1220,14 @@ int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_
1220 if (totlen != sizeof(struct jffs2_raw_xref)) 1220 if (totlen != sizeof(struct jffs2_raw_xref))
1221 goto out; 1221 goto out;
1222 1222
1223 rc = jffs2_reserve_space_gc(c, totlen, &phys_ofs, &length, JFFS2_SUMMARY_XREF_SIZE); 1223 rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XREF_SIZE);
1224 if (rc || length < totlen) { 1224 if (rc || length < totlen) {
1225 JFFS2_WARNING("%s: jffs2_reserve_space() = %d, request = %u\n", 1225 JFFS2_WARNING("%s: jffs2_reserve_space() = %d, request = %u\n",
1226 __FUNCTION__, rc, totlen); 1226 __FUNCTION__, rc, totlen);
1227 rc = rc ? rc : -EBADFD; 1227 rc = rc ? rc : -EBADFD;
1228 goto out; 1228 goto out;
1229 } 1229 }
1230 rc = save_xattr_ref(c, ref, phys_ofs); 1230 rc = save_xattr_ref(c, ref);
1231 if (!rc) 1231 if (!rc)
1232 dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n", 1232 dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n",
1233 ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node)); 1233 ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node));
diff --git a/fs/jffs2/xattr.h b/fs/jffs2/xattr.h
index e2aa2394ab64..2c199856c582 100644
--- a/fs/jffs2/xattr.h
+++ b/fs/jffs2/xattr.h
@@ -20,11 +20,11 @@
20struct jffs2_xattr_datum 20struct jffs2_xattr_datum
21{ 21{
22 void *always_null; 22 void *always_null;
23 u8 class;
24 u8 flags;
25 u16 xprefix; /* see JFFS2_XATTR_PREFIX_* */
26
27 struct jffs2_raw_node_ref *node; 23 struct jffs2_raw_node_ref *node;
24 uint8_t class;
25 uint8_t flags;
26 uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */
27
28 struct list_head xindex; /* chained from c->xattrindex[n] */ 28 struct list_head xindex; /* chained from c->xattrindex[n] */
29 uint32_t refcnt; /* # of xattr_ref refers this */ 29 uint32_t refcnt; /* # of xattr_ref refers this */
30 uint32_t xid; 30 uint32_t xid;
@@ -42,11 +42,11 @@ struct jffs2_inode_cache;
42struct jffs2_xattr_ref 42struct jffs2_xattr_ref
43{ 43{
44 void *always_null; 44 void *always_null;
45 u8 class; 45 struct jffs2_raw_node_ref *node;
46 u8 flags; /* Currently unused */ 46 uint8_t class;
47 uint8_t flags; /* Currently unused */
47 u16 unused; 48 u16 unused;
48 49
49 struct jffs2_raw_node_ref *node;
50 union { 50 union {
51 struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */ 51 struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
52 uint32_t ino; /* only used in scanning/building */ 52 uint32_t ino; /* only used in scanning/building */
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 fa2524157846..1e09e4c8f485 100644
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -30,17 +30,14 @@ struct mtd_oob_buf {
30#define MTD_NANDFLASH 4 30#define MTD_NANDFLASH 4
31#define MTD_DATAFLASH 6 31#define MTD_DATAFLASH 6
32 32
33#define MTD_CLEAR_BITS 1 // Bits can be cleared (flash) 33#define MTD_WRITEABLE 0x400 /* Device is writeable */
34#define MTD_SET_BITS 2 // Bits can be set 34#define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */
35#define MTD_ECC 128 // Device capable of automatic ECC
36#define MTD_PROGRAM_REGIONS 512 // Configurable Programming Regions
37 35
38// Some common devices / combinations of capabilities 36// Some common devices / combinations of capabilities
39#define MTD_CAP_ROM 0 37#define MTD_CAP_ROM 0
40#define MTD_CAP_RAM (MTD_CLEAR_BITS|MTD_SET_BITS) 38#define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
41#define MTD_CAP_NORFLASH (MTD_CLEAR_BITS) 39#define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
42#define MTD_CAP_NANDFLASH (MTD_CLEAR_BITS) 40#define MTD_CAP_NANDFLASH (MTD_WRITEABLE)
43#define MTD_WRITEABLE (MTD_CLEAR_BITS|MTD_SET_BITS)
44 41
45 42
46// Types of automatic ECC/Checksum available 43// Types of automatic ECC/Checksum available
@@ -65,7 +62,7 @@ struct mtd_info_user {
65 uint32_t flags; 62 uint32_t flags;
66 uint32_t size; // Total size of the MTD 63 uint32_t size; // Total size of the MTD
67 uint32_t erasesize; 64 uint32_t erasesize;
68 uint32_t oobblock; // Size of OOB blocks (e.g. 512) 65 uint32_t writesize;
69 uint32_t oobsize; // Amount of OOB data per block (e.g. 16) 66 uint32_t oobsize; // Amount of OOB data per block (e.g. 16)
70 uint32_t ecctype; 67 uint32_t ecctype;
71 uint32_t eccsize; 68 uint32_t eccsize;