Commit 4cbb9b80 authored by Thomas Gleixner's avatar Thomas Gleixner

Merge branch 'master' of /home/tglx/work/kernel/git/mtd-2.6/

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parents 6dfc6d25 9fe4854c
...@@ -545,12 +545,12 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd, ...@@ -545,12 +545,12 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
if (extp->MinorVersion >= '4') { if (extp->MinorVersion >= '4') {
struct cfi_intelext_programming_regioninfo *prinfo; struct cfi_intelext_programming_regioninfo *prinfo;
prinfo = (struct cfi_intelext_programming_regioninfo *)&extp->extra[offs]; prinfo = (struct cfi_intelext_programming_regioninfo *)&extp->extra[offs];
MTD_PROGREGION_SIZE(mtd) = cfi->interleave << prinfo->ProgRegShift; mtd->writesize = cfi->interleave << prinfo->ProgRegShift;
MTD_PROGREGION_CTRLMODE_VALID(mtd) = cfi->interleave * prinfo->ControlValid; MTD_PROGREGION_CTRLMODE_VALID(mtd) = cfi->interleave * prinfo->ControlValid;
MTD_PROGREGION_CTRLMODE_INVALID(mtd) = cfi->interleave * prinfo->ControlInvalid; MTD_PROGREGION_CTRLMODE_INVALID(mtd) = cfi->interleave * prinfo->ControlInvalid;
mtd->flags |= MTD_PROGRAM_REGIONS; mtd->flags &= ~MTD_BIT_WRITEABLE;
printk(KERN_DEBUG "%s: program region size/ctrl_valid/ctrl_inval = %d/%d/%d\n", printk(KERN_DEBUG "%s: program region size/ctrl_valid/ctrl_inval = %d/%d/%d\n",
map->name, MTD_PROGREGION_SIZE(mtd), map->name, mtd->writesize,
MTD_PROGREGION_CTRLMODE_VALID(mtd), MTD_PROGREGION_CTRLMODE_VALID(mtd),
MTD_PROGREGION_CTRLMODE_INVALID(mtd)); MTD_PROGREGION_CTRLMODE_INVALID(mtd));
} }
......
...@@ -238,9 +238,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map) ...@@ -238,9 +238,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
mtd->unlock = cfi_staa_unlock; mtd->unlock = cfi_staa_unlock;
mtd->suspend = cfi_staa_suspend; mtd->suspend = cfi_staa_suspend;
mtd->resume = cfi_staa_resume; mtd->resume = cfi_staa_resume;
mtd->flags = MTD_CAP_NORFLASH; mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE;
mtd->flags |= MTD_ECC; /* FIXME: Not all STMicro flashes have this */ mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
mtd->eccsize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
map->fldrv = &cfi_staa_chipdrv; map->fldrv = &cfi_staa_chipdrv;
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
mtd->name = map->name; mtd->name = map->name;
......
...@@ -579,7 +579,7 @@ void DoC2k_init(struct mtd_info *mtd) ...@@ -579,7 +579,7 @@ void DoC2k_init(struct mtd_info *mtd)
mtd->ecctype = MTD_ECC_RS_DiskOnChip; mtd->ecctype = MTD_ECC_RS_DiskOnChip;
mtd->size = 0; mtd->size = 0;
mtd->erasesize = 0; mtd->erasesize = 0;
mtd->oobblock = 512; mtd->writesize = 512;
mtd->oobsize = 16; mtd->oobsize = 16;
mtd->owner = THIS_MODULE; mtd->owner = THIS_MODULE;
mtd->erase = doc_erase; mtd->erase = doc_erase;
......
...@@ -361,7 +361,7 @@ void DoCMil_init(struct mtd_info *mtd) ...@@ -361,7 +361,7 @@ void DoCMil_init(struct mtd_info *mtd)
/* FIXME: erase size is not always 8KiB */ /* FIXME: erase size is not always 8KiB */
mtd->erasesize = 0x2000; mtd->erasesize = 0x2000;
mtd->oobblock = 512; mtd->writesize = 512;
mtd->oobsize = 16; mtd->oobsize = 16;
mtd->owner = THIS_MODULE; mtd->owner = THIS_MODULE;
mtd->erase = doc_erase; mtd->erase = doc_erase;
......
...@@ -483,7 +483,7 @@ void DoCMilPlus_init(struct mtd_info *mtd) ...@@ -483,7 +483,7 @@ void DoCMilPlus_init(struct mtd_info *mtd)
mtd->size = 0; mtd->size = 0;
mtd->erasesize = 0; mtd->erasesize = 0;
mtd->oobblock = 512; mtd->writesize = 512;
mtd->oobsize = 16; mtd->oobsize = 16;
mtd->owner = THIS_MODULE; mtd->owner = THIS_MODULE;
mtd->erase = doc_erase; mtd->erase = doc_erase;
......
...@@ -278,9 +278,9 @@ concat_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -278,9 +278,9 @@ concat_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
return -EINVAL; return -EINVAL;
/* Check alignment */ /* Check alignment */
if (mtd->oobblock > 1) { if (mtd->writesize > 1) {
loff_t __to = to; loff_t __to = to;
if (do_div(__to, mtd->oobblock) || (total_len % mtd->oobblock)) if (do_div(__to, mtd->writesize) || (total_len % mtd->writesize))
return -EINVAL; return -EINVAL;
} }
...@@ -334,7 +334,7 @@ concat_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -334,7 +334,7 @@ concat_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
*retlen += retsize; *retlen += retsize;
total_len -= wsize; total_len -= wsize;
if (concat->mtd.type == MTD_NANDFLASH && eccbuf) if (concat->mtd.type == MTD_NANDFLASH && eccbuf)
eccbuf += mtd->oobavail * (wsize / mtd->oobblock); eccbuf += mtd->oobavail * (wsize / mtd->writesize);
if (total_len == 0) if (total_len == 0)
break; break;
...@@ -833,7 +833,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c ...@@ -833,7 +833,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
concat->mtd.flags = subdev[0]->flags; concat->mtd.flags = subdev[0]->flags;
concat->mtd.size = subdev[0]->size; concat->mtd.size = subdev[0]->size;
concat->mtd.erasesize = subdev[0]->erasesize; concat->mtd.erasesize = subdev[0]->erasesize;
concat->mtd.oobblock = subdev[0]->oobblock; concat->mtd.writesize = subdev[0]->writesize;
concat->mtd.oobsize = subdev[0]->oobsize; concat->mtd.oobsize = subdev[0]->oobsize;
concat->mtd.ecctype = subdev[0]->ecctype; concat->mtd.ecctype = subdev[0]->ecctype;
concat->mtd.eccsize = subdev[0]->eccsize; concat->mtd.eccsize = subdev[0]->eccsize;
...@@ -881,7 +881,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c ...@@ -881,7 +881,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
subdev[i]->flags & MTD_WRITEABLE; subdev[i]->flags & MTD_WRITEABLE;
} }
concat->mtd.size += subdev[i]->size; concat->mtd.size += subdev[i]->size;
if (concat->mtd.oobblock != subdev[i]->oobblock || if (concat->mtd.writesize != subdev[i]->writesize ||
concat->mtd.oobsize != subdev[i]->oobsize || concat->mtd.oobsize != subdev[i]->oobsize ||
concat->mtd.ecctype != subdev[i]->ecctype || concat->mtd.ecctype != subdev[i]->ecctype ||
concat->mtd.eccsize != subdev[i]->eccsize || concat->mtd.eccsize != subdev[i]->eccsize ||
......
...@@ -398,7 +398,7 @@ int add_mtd_partitions(struct mtd_info *master, ...@@ -398,7 +398,7 @@ int add_mtd_partitions(struct mtd_info *master,
slave->mtd.type = master->type; slave->mtd.type = master->type;
slave->mtd.flags = master->flags & ~parts[i].mask_flags; slave->mtd.flags = master->flags & ~parts[i].mask_flags;
slave->mtd.size = parts[i].size; slave->mtd.size = parts[i].size;
slave->mtd.oobblock = master->oobblock; slave->mtd.writesize = master->writesize;
slave->mtd.oobsize = master->oobsize; slave->mtd.oobsize = master->oobsize;
slave->mtd.oobavail = master->oobavail; slave->mtd.oobavail = master->oobavail;
slave->mtd.ecctype = master->ecctype; slave->mtd.ecctype = master->ecctype;
......
...@@ -356,9 +356,9 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i ...@@ -356,9 +356,9 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i
if (command == NAND_CMD_SEQIN) { if (command == NAND_CMD_SEQIN) {
int readcmd; int readcmd;
if (column >= mtd->oobblock) { if (column >= mtd->writesize) {
/* OOB area */ /* OOB area */
column -= mtd->oobblock; column -= mtd->writesize;
readcmd = NAND_CMD_READOOB; readcmd = NAND_CMD_READOOB;
} else if (column < 256) { } else if (column < 256) {
/* First 256 bytes --> READ0 */ /* First 256 bytes --> READ0 */
......
...@@ -761,9 +761,9 @@ static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int colu ...@@ -761,9 +761,9 @@ static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int colu
if (command == NAND_CMD_SEQIN) { if (command == NAND_CMD_SEQIN) {
int readcmd; int readcmd;
if (column >= mtd->oobblock) { if (column >= mtd->writesize) {
/* OOB area */ /* OOB area */
column -= mtd->oobblock; column -= mtd->writesize;
readcmd = NAND_CMD_READOOB; readcmd = NAND_CMD_READOOB;
} else if (column < 256) { } else if (column < 256) {
/* First 256 bytes --> READ0 */ /* First 256 bytes --> READ0 */
...@@ -1093,8 +1093,8 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch ...@@ -1093,8 +1093,8 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch
size_t retlen; size_t retlen;
for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); ret = mtd->read(mtd, offs, mtd->writesize, &retlen, buf);
if (retlen != mtd->oobblock) if (retlen != mtd->writesize)
continue; continue;
if (ret) { if (ret) {
printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", offs); 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,8 +1118,8 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch
/* Only one mediaheader was found. We want buf to contain a /* Only one mediaheader was found. We want buf to contain a
mediaheader on return, so we'll have to re-read the one we found. */ mediaheader on return, so we'll have to re-read the one we found. */
offs = doc->mh0_page << this->page_shift; offs = doc->mh0_page << this->page_shift;
ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); ret = mtd->read(mtd, offs, mtd->writesize, &retlen, buf);
if (retlen != mtd->oobblock) { if (retlen != mtd->writesize) {
/* Insanity. Give up. */ /* Insanity. Give up. */
printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n"); printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n");
return 0; return 0;
...@@ -1139,7 +1139,7 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partitio ...@@ -1139,7 +1139,7 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partitio
unsigned blocks, maxblocks; unsigned blocks, maxblocks;
int offs, numheaders; int offs, numheaders;
buf = kmalloc(mtd->oobblock, GFP_KERNEL); buf = kmalloc(mtd->writesize, GFP_KERNEL);
if (!buf) { if (!buf) {
printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n");
return 0; return 0;
...@@ -1247,7 +1247,7 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partiti ...@@ -1247,7 +1247,7 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partiti
if (inftl_bbt_write) if (inftl_bbt_write)
end -= (INFTL_BBT_RESERVED_BLOCKS << this->phys_erase_shift); end -= (INFTL_BBT_RESERVED_BLOCKS << this->phys_erase_shift);
buf = kmalloc(mtd->oobblock, GFP_KERNEL); buf = kmalloc(mtd->writesize, GFP_KERNEL);
if (!buf) { if (!buf) {
printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n");
return 0; return 0;
......
...@@ -572,9 +572,9 @@ static void nand_command(struct mtd_info *mtd, unsigned command, int column, ...@@ -572,9 +572,9 @@ static void nand_command(struct mtd_info *mtd, unsigned command, int column,
if (command == NAND_CMD_SEQIN) { if (command == NAND_CMD_SEQIN) {
int readcmd; int readcmd;
if (column >= mtd->oobblock) { if (column >= mtd->writesize) {
/* OOB area */ /* OOB area */
column -= mtd->oobblock; column -= mtd->writesize;
readcmd = NAND_CMD_READOOB; readcmd = NAND_CMD_READOOB;
} else if (column < 256) { } else if (column < 256) {
/* First 256 bytes --> READ0 */ /* First 256 bytes --> READ0 */
...@@ -670,7 +670,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column, ...@@ -670,7 +670,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column,
/* Emulate NAND_CMD_READOOB */ /* Emulate NAND_CMD_READOOB */
if (command == NAND_CMD_READOOB) { if (command == NAND_CMD_READOOB) {
column += mtd->oobblock; column += mtd->writesize;
command = NAND_CMD_READ0; command = NAND_CMD_READ0;
} }
...@@ -895,7 +895,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag ...@@ -895,7 +895,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
/* No ecc, write all */ /* No ecc, write all */
case NAND_ECC_NONE: case NAND_ECC_NONE:
printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n");
this->write_buf(mtd, this->data_poi, mtd->oobblock); this->write_buf(mtd, this->data_poi, mtd->writesize);
break; break;
/* Software ecc 3/256, write all */ /* 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,7 +906,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
oob_buf[oob_config[eccidx]] = ecc_code[i]; oob_buf[oob_config[eccidx]] = ecc_code[i];
datidx += this->ecc.size; datidx += this->ecc.size;
} }
this->write_buf(mtd, this->data_poi, mtd->oobblock); this->write_buf(mtd, this->data_poi, mtd->writesize);
break; break;
default: default:
eccbytes = this->ecc.bytes; eccbytes = this->ecc.bytes;
...@@ -1167,9 +1167,9 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -1167,9 +1167,9 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
page = realpage & this->pagemask; page = realpage & this->pagemask;
/* Get raw starting column */ /* Get raw starting column */
col = from & (mtd->oobblock - 1); col = from & (mtd->writesize - 1);
end = mtd->oobblock; end = mtd->writesize;
ecc = this->ecc.size; ecc = this->ecc.size;
eccbytes = this->ecc.bytes; eccbytes = this->ecc.bytes;
...@@ -1327,7 +1327,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -1327,7 +1327,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
buf[read++] = data_poi[j]; buf[read++] = data_poi[j];
this->pagebuf = realpage; this->pagebuf = realpage;
} else } else
read += mtd->oobblock; read += mtd->writesize;
/* Apply delay or wait for ready/busy pin /* Apply delay or wait for ready/busy pin
* Do this before the AUTOINCR check, so no problems * 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,7 +1485,7 @@ int nand_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, s
int chip = (int)(from >> this->chip_shift); int chip = (int)(from >> this->chip_shift);
int sndcmd = 1; int sndcmd = 1;
int cnt = 0; int cnt = 0;
int pagesize = mtd->oobblock + mtd->oobsize; int pagesize = mtd->writesize + mtd->oobsize;
int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1;
/* Do not allow reads past end of device */ /* 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,7 +1587,7 @@ static uint8_t *nand_prepare_oobbuf(struct mtd_info *mtd, uint8_t *fsbuf, struct
return this->oob_buf; return this->oob_buf;
} }
#define NOTALIGNED(x) (x & (mtd->oobblock-1)) != 0 #define NOTALIGNED(x) (x & (mtd->writesize-1)) != 0
/** /**
* nand_write - [MTD Interface] compability function for nand_write_ecc * 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,7 +1700,7 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
/* Next oob page */ /* Next oob page */
oob += mtd->oobsize; oob += mtd->oobsize;
/* Update written bytes count */ /* Update written bytes count */
written += mtd->oobblock; written += mtd->writesize;
if (written == len) if (written == len)
goto cmp; goto cmp;
...@@ -1811,7 +1811,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r ...@@ -1811,7 +1811,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r
if (NAND_MUST_PAD(this)) { if (NAND_MUST_PAD(this)) {
/* Write out desired data */ /* Write out desired data */
this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask); this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page & this->pagemask);
/* prepad 0xff for partial programming */ /* prepad 0xff for partial programming */
this->write_buf(mtd, ffchars, column); this->write_buf(mtd, ffchars, column);
/* write data */ /* 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,7 +1820,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r
this->write_buf(mtd, ffchars, mtd->oobsize - (len + column)); this->write_buf(mtd, ffchars, mtd->oobsize - (len + column));
} else { } else {
/* Write out desired data */ /* Write out desired data */
this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask); this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize + column, page & this->pagemask);
/* write data */ /* write data */
this->write_buf(mtd, buf, len); this->write_buf(mtd, buf, len);
} }
...@@ -1953,7 +1953,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign ...@@ -1953,7 +1953,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
/* If the given tuple is >= pagesize then /* If the given tuple is >= pagesize then
* write it out from the iov * write it out from the iov
*/ */
if ((vecs->iov_len - len) >= mtd->oobblock) { if ((vecs->iov_len - len) >= mtd->writesize) {
/* Calc number of pages we can write /* Calc number of pages we can write
* out of this iov in one go */ * out of this iov in one go */
numpages = (vecs->iov_len - len) >> this->page_shift; 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,8 +1973,8 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
&oobbuf[oob], oobsel, i != numpages); &oobbuf[oob], oobsel, i != numpages);
if (ret) if (ret)
goto out; goto out;
this->data_poi += mtd->oobblock; this->data_poi += mtd->writesize;
len += mtd->oobblock; len += mtd->writesize;
oob += mtd->oobsize; oob += mtd->oobsize;
page++; page++;
} }
...@@ -1989,7 +1989,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign ...@@ -1989,7 +1989,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
* tuple until we have a full page to write * tuple until we have a full page to write
*/ */
int cnt = 0; int cnt = 0;
while (cnt < mtd->oobblock) { while (cnt < mtd->writesize) {
if (vecs->iov_base != NULL && vecs->iov_len) if (vecs->iov_base != NULL && vecs->iov_len)
this->data_buf[cnt++] = ((uint8_t *) vecs->iov_base)[len++]; this->data_buf[cnt++] = ((uint8_t *) vecs->iov_base)[len++];
/* Check, if we have to switch to the next tuple */ /* 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,7 +2015,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
if (ret) if (ret)
goto out; goto out;
written += mtd->oobblock * numpages; written += mtd->writesize * numpages;
/* All done ? */ /* All done ? */
if (!count) if (!count)
break; break;
...@@ -2351,7 +2351,7 @@ static int nand_allocate_kmem(struct mtd_info *mtd, struct nand_chip *this) ...@@ -2351,7 +2351,7 @@ static int nand_allocate_kmem(struct mtd_info *mtd, struct nand_chip *this)
} }
if (!this->data_buf) { if (!this->data_buf) {
len = mtd->oobblock + mtd->oobsize; len = mtd->writesize + mtd->oobsize;
this->data_buf = kmalloc(len, GFP_KERNEL); this->data_buf = kmalloc(len, GFP_KERNEL);
if (!this->data_buf) if (!this->data_buf)
goto outerr; goto outerr;
...@@ -2455,10 +2455,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, ...@@ -2455,10 +2455,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
/* The 4th id byte is the important one */ /* The 4th id byte is the important one */
extid = this->read_byte(mtd); extid = this->read_byte(mtd);
/* Calc pagesize */ /* Calc pagesize */
mtd->oobblock = 1024 << (extid & 0x3); mtd->writesize = 1024 << (extid & 0x3);
extid >>= 2; extid >>= 2;
/* Calc oobsize */ /* Calc oobsize */
mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9); mtd->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9);
extid >>= 2; extid >>= 2;
/* Calc blocksize. Blocksize is multiples of 64KiB */ /* Calc blocksize. Blocksize is multiples of 64KiB */
mtd->erasesize = (64 * 1024) << (extid & 0x03); mtd->erasesize = (64 * 1024) << (extid & 0x03);
...@@ -2471,8 +2471,8 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, ...@@ -2471,8 +2471,8 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
* Old devices have this data hardcoded in the device id table * Old devices have this data hardcoded in the device id table
*/ */
mtd->erasesize = nand_flash_ids[i].erasesize; mtd->erasesize = nand_flash_ids[i].erasesize;
mtd->oobblock = nand_flash_ids[i].pagesize; mtd->writesize = nand_flash_ids[i].pagesize;
mtd->oobsize = mtd->oobblock / 32; mtd->oobsize = mtd->writesize / 32;
busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16; busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16;
} }
...@@ -2497,7 +2497,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, ...@@ -2497,7 +2497,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
} }
/* Calculate the address shift from the page size */ /* Calculate the address shift from the page size */
this->page_shift = ffs(mtd->oobblock) - 1; this->page_shift = ffs(mtd->writesize) - 1;
/* Convert chipsize to number of pages per chip -1. */ /* Convert chipsize to number of pages per chip -1. */
this->pagemask = (this->chipsize >> this->page_shift) - 1; this->pagemask = (this->chipsize >> this->page_shift) - 1;
...@@ -2506,7 +2506,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, ...@@ -2506,7 +2506,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
this->chip_shift = ffs(this->chipsize) - 1; this->chip_shift = ffs(this->chipsize) - 1;
/* Set the bad block position */ /* Set the bad block position */
this->badblockpos = mtd->oobblock > 512 ? this->badblockpos = mtd->writesize > 512 ?
NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS;
/* Get chip options, preserve non chip based options */ /* 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,7 +2531,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
this->erase_cmd = single_erase_cmd; this->erase_cmd = single_erase_cmd;
/* Do not replace user supplied command function ! */ /* Do not replace user supplied command function ! */
if (mtd->oobblock > 512 && this->cmdfunc == nand_command) if (mtd->writesize > 512 && this->cmdfunc == nand_command)
this->cmdfunc = nand_command_lp; this->cmdfunc = nand_command_lp;
printk(KERN_INFO "NAND device: Manufacturer ID:" printk(KERN_INFO "NAND device: Manufacturer ID:"
...@@ -2657,11 +2657,11 @@ int nand_scan(struct mtd_info *mtd, int maxchips) ...@@ -2657,11 +2657,11 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
"Hardware ECC not possible\n"); "Hardware ECC not possible\n");
BUG(); BUG();
} }
if (mtd->oobblock >= this->ecc.size) if (mtd->writesize >= this->ecc.size)
break; break;
printk(KERN_WARNING "%d byte HW ECC not possible on " printk(KERN_WARNING "%d byte HW ECC not possible on "
"%d byte page size, fallback to SW ECC\n", "%d byte page size, fallback to SW ECC\n",
this->ecc.size, mtd->oobblock); this->ecc.size, mtd->writesize);
this->ecc.mode = NAND_ECC_SOFT; this->ecc.mode = NAND_ECC_SOFT;
case NAND_ECC_SOFT: case NAND_ECC_SOFT:
...@@ -2674,7 +2674,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips) ...@@ -2674,7 +2674,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
case NAND_ECC_NONE: case NAND_ECC_NONE:
printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. " printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. "
"This is not recommended !!\n"); "This is not recommended !!\n");
this->ecc.size = mtd->oobblock; this->ecc.size = mtd->writesize;
this->ecc.bytes = 0; this->ecc.bytes = 0;
break; break;
default: default:
...@@ -2687,8 +2687,8 @@ int nand_scan(struct mtd_info *mtd, int maxchips) ...@@ -2687,8 +2687,8 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
* Set the number of read / write steps for one page depending on ECC * Set the number of read / write steps for one page depending on ECC
* mode * mode
*/ */
this->ecc.steps = mtd->oobblock / this->ecc.size; this->ecc.steps = mtd->writesize / this->ecc.size;
if(this->ecc.steps * this->ecc.size != mtd->oobblock) { if(this->ecc.steps * this->ecc.size != mtd->writesize) {
printk(KERN_WARNING "Invalid ecc parameters\n"); printk(KERN_WARNING "Invalid ecc parameters\n");
BUG(); BUG();
} }
...@@ -2706,7 +2706,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips) ...@@ -2706,7 +2706,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
/* Fill in remaining MTD driver data */ /* Fill in remaining MTD driver data */
mtd->type = MTD_NANDFLASH; mtd->type = MTD_NANDFLASH;
mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC; mtd->flags = MTD_CAP_NANDFLASH;
mtd->ecctype = MTD_ECC_SW; mtd->ecctype = MTD_ECC_SW;
mtd->erase = nand_erase; mtd->erase = nand_erase;
mtd->point = NULL; mtd->point = NULL;
......
...@@ -247,15 +247,15 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des ...@@ -247,15 +247,15 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des
/* Read the primary version, if available */ /* Read the primary version, if available */
if (td->options & NAND_BBT_VERSION) { if (td->options & NAND_BBT_VERSION) {
nand_read_raw(mtd, buf, td->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); nand_read_raw(mtd, buf, td->pages[0] << this->page_shift, mtd->writesize, mtd->oobsize);
td->version[0] = buf[mtd->oobblock + td->veroffs]; td->version[0] = buf[mtd->writesize + td->veroffs];
printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]); printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]);
} }
/* Read the mirror version, if available */ /* Read the mirror version, if available */
if (md && (md->options & NAND_BBT_VERSION)) { if (md && (md->options & NAND_BBT_VERSION)) {
nand_read_raw(mtd, buf, md->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); nand_read_raw(mtd, buf, md->pages[0] << this->page_shift, mtd->writesize, mtd->oobsize);
md->version[0] = buf[mtd->oobblock + md->veroffs]; md->version[0] = buf[mtd->writesize + md->veroffs];
printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]); printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]);
} }
...@@ -298,8 +298,8 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr ...@@ -298,8 +298,8 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
readlen = bd->len; readlen = bd->len;
} else { } else {
/* Full page content should be read */ /* Full page content should be read */
scanlen = mtd->oobblock + mtd->oobsize; scanlen = mtd->writesize + mtd->oobsize;
readlen = len * mtd->oobblock; readlen = len * mtd->writesize;
ooblen = len * mtd->oobsize; ooblen = len * mtd->oobsize;
} }
...@@ -334,7 +334,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr ...@@ -334,7 +334,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
/* Read the full oob until read_oob is fixed to /* Read the full oob until read_oob is fixed to
* handle single byte reads for 16 bit buswidth */ * handle single byte reads for 16 bit buswidth */
ret = mtd->read_oob(mtd, from + j * mtd->oobblock, mtd->oobsize, &retlen, buf); ret = mtd->read_oob(mtd, from + j * mtd->writesize, mtd->oobsize, &retlen, buf);
if (ret) if (ret)
return ret; return ret;
...@@ -345,7 +345,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr ...@@ -345,7 +345,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
break; break;
} }
} else { } else {
if (check_pattern(&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { if (check_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {
this->bbt[i >> 3] |= 0x03 << (i & 0x6); this->bbt[i >> 3] |= 0x03 << (i & 0x6);
printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
i >> 1, (unsigned int)from); 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,7 +381,7 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
struct nand_chip *this = mtd->priv; struct nand_chip *this = mtd->priv;
int i, chips; int i, chips;
int bits, startblock, block, dir; int bits, startblock, block, dir;
int scanlen = mtd->oobblock + mtd->oobsize; int scanlen = mtd->writesize + mtd->oobsize;
int bbtblocks; int bbtblocks;
/* Search direction top -> down ? */ /* Search direction top -> down ? */
...@@ -414,11 +414,11 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr ...@@ -414,11 +414,11 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
for (block = 0; block < td->maxblocks; block++) { for (block = 0; block < td->maxblocks; block++) {
int actblock = startblock + dir * block; int actblock = startblock + dir * block;
/* Read first page */ /* Read first page */
nand_read_raw(mtd, buf, actblock << this->bbt_erase_shift, mtd->oobblock, mtd->oobsize); nand_read_raw(mtd, buf, actblock << this->bbt_erase_shift, mtd->writesize, mtd->oobsize);
if (!check_pattern(buf, scanlen, mtd->oobblock, td)) { if (!check_pattern(buf, scanlen, mtd->writesize, td)) {
td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift); td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift);
if (td->options & NAND_BBT_VERSION) { if (td->options & NAND_BBT_VERSION) {
td->version[i] = buf[mtd->oobblock + td->veroffs]; td->version[i] = buf[mtd->writesize + td->veroffs];
} }
break; break;
} }
...@@ -586,7 +586,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, ...@@ -586,7 +586,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
/* Calc length */ /* Calc length */
len = (size_t) (numblocks >> sft); len = (size_t) (numblocks >> sft);
/* Make it page aligned ! */ /* Make it page aligned ! */
len = (len + (mtd->oobblock - 1)) & ~(mtd->oobblock - 1); len = (len + (mtd->writesize - 1)) & ~(mtd->writesize - 1);
/* Preset the buffer with 0xff */ /* Preset the buffer with 0xff */
memset(buf, 0xff, len + (len >> this->page_shift) * mtd->oobsize); memset(buf, 0xff, len + (len >> this->page_shift) * mtd->oobsize);
offs = 0; offs = 0;
...@@ -1063,13 +1063,13 @@ int nand_default_bbt(struct mtd_info *mtd) ...@@ -1063,13 +1063,13 @@ int nand_default_bbt(struct mtd_info *mtd)
this->bbt_md = &bbt_mirror_descr; this->bbt_md = &bbt_mirror_descr;
} }
if (!this->badblock_pattern) { if (!this->badblock_pattern) {
this->badblock_pattern = (mtd->oobblock > 512) ? &largepage_flashbased : &smallpage_flashbased; this->badblock_pattern = (mtd->writesize > 512) ? &largepage_flashbased : &smallpage_flashbased;
} }
} else { } else {
this->bbt_td = NULL; this->bbt_td = NULL;
this->bbt_md = NULL; this->bbt_md = NULL;
if (!this->badblock_pattern) { if (!this->badblock_pattern) {
this->badblock_pattern = (mtd->oobblock > 512) ? this->badblock_pattern = (mtd->writesize > 512) ?
&largepage_memorybased : &smallpage_memorybased; &largepage_memorybased : &smallpage_memorybased;
} }
} }
......
...@@ -369,7 +369,7 @@ init_nandsim(struct mtd_info *mtd) ...@@ -369,7 +369,7 @@ init_nandsim(struct mtd_info *mtd)
/* Initialize the NAND flash parameters */ /* Initialize the NAND flash parameters */
ns->busw = chip->options & NAND_BUSWIDTH_16 ? 16 : 8; ns->busw = chip->options & NAND_BUSWIDTH_16 ? 16 : 8;
ns->geom.totsz = mtd->size; ns->geom.totsz = mtd->size;
ns->geom.pgsz = mtd->oobblock; ns->geom.pgsz = mtd->writesize;
ns->geom.oobsz = mtd->oobsize; ns->geom.oobsz = mtd->oobsize;
ns->geom.secsz = mtd->erasesize; ns->geom.secsz = mtd->erasesize;
ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz; ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz;
......
...@@ -487,7 +487,7 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int s ...@@ -487,7 +487,7 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int s
if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { if (!(rtn & ERR_STAT_ECC_AVAILABLE)) {
er_stat |= 1 << 1; /* err_ecc_not_avail */ er_stat |= 1 << 1; /* err_ecc_not_avail */
} else { } else {
len = mtd->oobblock; len = mtd->writesize;
buf = kmalloc(len, GFP_KERNEL); buf = kmalloc(len, GFP_KERNEL);
if (!buf) { if (!buf) {
printk(KERN_ERR "rtc_from4_errstat: Out of memory!\n"); printk(KERN_ERR "rtc_from4_errstat: Out of memory!\n");
......
...@@ -354,7 +354,7 @@ static inline int onenand_bufferram_offset(struct mtd_info *mtd, int area) ...@@ -354,7 +354,7 @@ static inline int onenand_bufferram_offset(struct mtd_info *mtd, int area)
if (ONENAND_CURRENT_BUFFERRAM(this)) { if (ONENAND_CURRENT_BUFFERRAM(this)) {
if (area == ONENAND_DATARAM) if (area == ONENAND_DATARAM)
return mtd->oobblock; return mtd->writesize;
if (area == ONENAND_SPARERAM) if (area == ONENAND_SPARERAM)
return mtd->oobsize; return mtd->oobsize;
} }
...@@ -632,14 +632,14 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -632,14 +632,14 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
/* TODO handling oob */ /* TODO handling oob */
while (read < len) { while (read < len) {
thislen = min_t(int, mtd->oobblock, len - read); thislen = min_t(int, mtd->writesize, len - read);
column = from & (mtd->oobblock - 1); column = from & (mtd->writesize - 1);
if (column + thislen > mtd->oobblock) if (column + thislen > mtd->writesize)
thislen = mtd->oobblock - column; thislen = mtd->writesize - column;
if (!onenand_check_bufferram(mtd, from)) { if (!onenand_check_bufferram(mtd, from)) {
this->command(mtd, ONENAND_CMD_READ, from, mtd->oobblock); this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize);
ret = this->wait(mtd, FL_READING); ret = this->wait(mtd, FL_READING);
/* First copy data and check return value for ECC handling */ /* 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,7 +752,7 @@ static int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
/* Read more? */ /* Read more? */
if (read < len) { if (read < len) {
/* Page size */ /* Page size */
from += mtd->oobblock; from += mtd->writesize;
column = 0; column = 0;
} }
} }
...@@ -809,7 +809,7 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr) ...@@ -809,7 +809,7 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
void __iomem *dataram0, *dataram1; void __iomem *dataram0, *dataram1;
int ret = 0; int ret = 0;
this->command(mtd, ONENAND_CMD_READ, addr, mtd->oobblock); this->command(mtd, ONENAND_CMD_READ, addr, mtd->writesize);
ret = this->wait(mtd, FL_READING); ret = this->wait(mtd, FL_READING);
if (ret) if (ret)
...@@ -819,9 +819,9 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr) ...@@ -819,9 +819,9 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
/* Check, if the two dataram areas are same */ /* Check, if the two dataram areas are same */
dataram0 = this->base + ONENAND_DATARAM; dataram0 = this->base + ONENAND_DATARAM;
dataram1 = dataram0 + mtd->oobblock; dataram1 = dataram0 + mtd->writesize;
if (memcmp(dataram0, dataram1, mtd->oobblock)) if (memcmp(dataram0, dataram1, mtd->writesize))
return -EBADMSG; return -EBADMSG;
return 0; return 0;
...@@ -831,7 +831,7 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr) ...@@ -831,7 +831,7 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
#define onenand_verify_oob(...) (0) #define onenand_verify_oob(...) (0)
#endif #endif
#define NOTALIGNED(x) ((x & (mtd->oobblock - 1)) != 0) #define NOTALIGNED(x) ((x & (mtd->writesize - 1)) != 0)
/** /**
* onenand_write_ecc - [MTD Interface] OneNAND write with ECC * 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,14 +875,14 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
/* Loop until all data write */ /* Loop until all data write */
while (written < len) { while (written < len) {
int thislen = min_t(int, mtd->oobblock, len - written); int thislen = min_t(int, mtd->writesize, len - written);
this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock); this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->writesize);
this->write_bufferram(mtd, ONENAND_DATARAM, buf, 0, thislen); this->write_bufferram(mtd, ONENAND_DATARAM, buf, 0, thislen);
this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock); this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
onenand_update_bufferram(mtd, to, 1); onenand_update_bufferram(mtd, to, 1);
...@@ -1070,10 +1070,10 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -1070,10 +1070,10 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
* If the given tuple is >= pagesize then * If the given tuple is >= pagesize then
* write it out from the iov * write it out from the iov
*/ */
if ((vecs->iov_len - len) >= mtd->oobblock) { if ((vecs->iov_len - len) >= mtd->writesize) {
pbuf = vecs->iov_base + len; pbuf = vecs->iov_base + len;
len += mtd->oobblock; len += mtd->writesize;
/* Check, if we have to switch to the next tuple */ /* Check, if we have to switch to the next tuple */
if (len >= (int) vecs->iov_len) { if (len >= (int) vecs->iov_len) {
...@@ -1083,8 +1083,8 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -1083,8 +1083,8 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
} }
} else { } else {
int cnt = 0, thislen; int cnt = 0, thislen;
while (cnt < mtd->oobblock) { while (cnt < mtd->writesize) {
thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len); thislen = min_t(int, mtd->writesize - cnt, vecs->iov_len - len);
memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen); memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen);
cnt += thislen; cnt += thislen;
len += thislen; len += thislen;
...@@ -1098,12 +1098,12 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -1098,12 +1098,12 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
} }
} }
this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock); this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->writesize);
this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->oobblock); this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->writesize);
this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock); this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
onenand_update_bufferram(mtd, to, 1); onenand_update_bufferram(mtd, to, 1);
...@@ -1121,9 +1121,9 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -1121,9 +1121,9 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
goto out; goto out;
} }
written += mtd->oobblock; written += mtd->writesize;
to += mtd->oobblock; to += mtd->writesize;
} }
out: out:
...@@ -1467,11 +1467,11 @@ static int do_otp_write(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -1467,11 +1467,11 @@ static int do_otp_write(struct mtd_info *mtd, loff_t from, size_t len,
int ret; int ret;
/* Force buffer page aligned */ /* Force buffer page aligned */
if (len < mtd->oobblock) { if (len < mtd->writesize) {
memcpy(this->page_buf, buf, len); memcpy(this->page_buf, buf, len);
memset(this->page_buf + len, 0xff, mtd->oobblock - len); memset(this->page_buf + len, 0xff, mtd->writesize - len);
pbuf = this->page_buf; pbuf = this->page_buf;
len = mtd->oobblock; len = mtd->writesize;
} }
/* Enter OTP access mode */ /* Enter OTP access mode */
...@@ -1546,12 +1546,12 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -1546,12 +1546,12 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
otp_pages = 10; otp_pages = 10;
if (mode == MTD_OTP_FACTORY) { if (mode == MTD_OTP_FACTORY) {
from += mtd->oobblock * otp_pages; from += mtd->writesize * otp_pages;
otp_pages = 64 - otp_pages; otp_pages = 64 - otp_pages;
} }
/* Check User/Factory boundary */ /* Check User/Factory boundary */
if (((mtd->oobblock * otp_pages) - (from + len)) < 0) if (((mtd->writesize * otp_pages) - (from + len)) < 0)
return 0; return 0;
while (len > 0 && otp_pages > 0) { 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,10 +1564,10 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
otpinfo = (struct otp_info *) buf; otpinfo = (struct otp_info *) buf;
otpinfo->start = from; otpinfo->start = from;
otpinfo->length = mtd->oobblock; otpinfo->length = mtd->writesize;
otpinfo->locked = 0; otpinfo->locked = 0;
from += mtd->oobblock; from += mtd->writesize;
buf += sizeof(struct otp_info); buf += sizeof(struct otp_info);
*retlen += sizeof(struct otp_info); *retlen += sizeof(struct otp_info);
} else { } else {
...@@ -1811,15 +1811,15 @@ static int onenand_probe(struct mtd_info *mtd) ...@@ -1811,15 +1811,15 @@ static int onenand_probe(struct mtd_info *mtd)
/* OneNAND page size & block size */ /* OneNAND page size & block size */
/* The data buffer size is equal to page size */ /* The data buffer size is equal to page size */
mtd->oobblock = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE); mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
mtd->oobsize = mtd->oobblock >> 5; mtd->oobsize = mtd->writesize >> 5;
/* Pagers per block is always 64 in OneNAND */ /* Pagers per block is always 64 in OneNAND */
mtd->erasesize = mtd->oobblock << 6; mtd->erasesize = mtd->writesize << 6;
this->erase_shift = ffs(mtd->erasesize) - 1; this->erase_shift = ffs(mtd->erasesize) - 1;
this->page_shift = ffs(mtd->oobblock) - 1; this->page_shift = ffs(mtd->writesize) - 1;
this->ppb_shift = (this->erase_shift - this->page_shift); this->ppb_shift = (this->erase_shift - this->page_shift);
this->page_mask = (mtd->erasesize / mtd->oobblock) - 1; this->page_mask = (mtd->erasesize / mtd->writesize) - 1;
/* REVIST: Multichip handling */ /* REVIST: Multichip handling */
...@@ -1909,7 +1909,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips) ...@@ -1909,7 +1909,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
/* Allocate buffers, if necessary */ /* Allocate buffers, if necessary */
if (!this->page_buf) { if (!this->page_buf) {
size_t len; size_t len;
len = mtd->oobblock + mtd->oobsize; len = mtd->writesize + mtd->oobsize;
this->page_buf = kmalloc(len, GFP_KERNEL); this->page_buf = kmalloc(len, GFP_KERNEL);
if (!this->page_buf) { if (!this->page_buf) {
printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n"); 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,7 +1943,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
/* Fill in remaining MTD driver data */ /* Fill in remaining MTD driver data */
mtd->type = MTD_NANDFLASH; mtd->type = MTD_NANDFLASH;
mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC; mtd->flags = MTD_CAP_NANDFLASH;
mtd->ecctype = MTD_ECC_SW; mtd->ecctype = MTD_ECC_SW;
mtd->erase = onenand_erase; mtd->erase = onenand_erase;
mtd->point = NULL; mtd->point = NULL;
......
...@@ -87,13 +87,13 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr ...@@ -87,13 +87,13 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
/* No need to read pages fully, /* No need to read pages fully,
* just read required OOB bytes */ * just read required OOB bytes */
ret = mtd->read_oob(mtd, from + j * mtd->oobblock + bd->offs, ret = mtd->read_oob(mtd, from + j * mtd->writesize + bd->offs,
readlen, &retlen, &buf[0]); readlen, &retlen, &buf[0]);
if (ret) if (ret)
return ret; return ret;
if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {
bbm->bbt[i >> 3] |= 0x03 << (i & 0x6); bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);
printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
i >> 1, (unsigned int) from); i >> 1, (unsigned int) from);
......
...@@ -308,7 +308,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -308,7 +308,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
struct jffs2_full_dnode *fn; struct jffs2_full_dnode *fn;
struct jffs2_full_dirent *fd; struct jffs2_full_dirent *fd;
int namelen; int namelen;
uint32_t alloclen, phys_ofs; uint32_t alloclen;
int ret, targetlen = strlen(target); int ret, targetlen = strlen(target);
/* FIXME: If you care. We'd need to use frags for the target /* 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,8 +327,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
* Just the node will do for now, though * Just the node will do for now, though
*/ */
namelen = dentry->d_name.len; namelen = dentry->d_name.len;
ret = jffs2_reserve_space(c, sizeof(*ri) + targetlen, &phys_ofs, &alloclen, ret = jffs2_reserve_space(c, sizeof(*ri) + targetlen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
if (ret) { if (ret) {
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
...@@ -356,7 +356,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -356,7 +356,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
ri->data_crc = cpu_to_je32(crc32(0, target, targetlen)); ri->data_crc = cpu_to_je32(crc32(0, target, targetlen));
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
fn = jffs2_write_dnode(c, f, ri, target, targetlen, phys_ofs, ALLOC_NORMAL); fn = jffs2_write_dnode(c, f, ri, target, targetlen, ALLOC_NORMAL);
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
...@@ -400,8 +400,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -400,8 +400,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
return ret; return ret;
} }
ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
if (ret) { if (ret) {
/* Eep. */ /* Eep. */
jffs2_clear_inode(inode); jffs2_clear_inode(inode);
...@@ -433,7 +433,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -433,7 +433,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, ALLOC_NORMAL);
if (IS_ERR(fd)) { if (IS_ERR(fd)) {
/* dirent failed to write. Delete the inode normally /* 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,7 +471,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
struct jffs2_full_dnode *fn; struct jffs2_full_dnode *fn;
struct jffs2_full_dirent *fd; struct jffs2_full_dirent *fd;
int namelen; int namelen;
uint32_t alloclen, phys_ofs; uint32_t alloclen;
int ret; int ret;
mode |= S_IFDIR; mode |= S_IFDIR;
...@@ -486,8 +486,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) ...@@ -486,8 +486,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
* Just the node will do for now, though * Just the node will do for now, though
*/ */
namelen = dentry->d_name.len; namelen = dentry->d_name.len;
ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL, ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL,
JFFS2_SUMMARY_INODE_SIZE); JFFS2_SUMMARY_INODE_SIZE);
if (ret) { if (ret) {
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
...@@ -512,7 +512,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) ...@@ -512,7 +512,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
ri->data_crc = cpu_to_je32(0); ri->data_crc = cpu_to_je32(0);
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, ALLOC_NORMAL); fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL);
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
...@@ -542,8 +542,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) ...@@ -542,8 +542,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
return ret; return ret;
} }
ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
if (ret) { if (ret) {
/* Eep. */ /* Eep. */
jffs2_clear_inode(inode); jffs2_clear_inode(inode);
...@@ -575,7 +575,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) ...@@ -575,7 +575,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, ALLOC_NORMAL);
if (IS_ERR(fd)) { if (IS_ERR(fd)) {
/* dirent failed to write. Delete the inode normally /* 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,7 +631,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
int namelen; int namelen;
union jffs2_device_node dev; union jffs2_device_node dev;
int devlen = 0; int devlen = 0;
uint32_t alloclen, phys_ofs; uint32_t alloclen;
int ret; int ret;
if (!new_valid_dev(rdev)) if (!new_valid_dev(rdev))
...@@ -650,7 +650,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de ...@@ -650,7 +650,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
* Just the node will do for now, though * Just the node will do for now, though
*/ */
namelen = dentry->d_name.len; namelen = dentry->d_name.len;
ret = jffs2_reserve_space(c, sizeof(*ri) + devlen, &phys_ofs, &alloclen, ret = jffs2_reserve_space(c, sizeof(*ri) + devlen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
if (ret) { if (ret) {
...@@ -678,7 +678,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de ...@@ -678,7 +678,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen)); ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen));
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, phys_ofs, ALLOC_NORMAL); fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, ALLOC_NORMAL);
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
...@@ -708,8 +708,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de ...@@ -708,8 +708,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
return ret; return ret;
} }
ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
if (ret) { if (ret) {
/* Eep. */ /* Eep. */
jffs2_clear_inode(inode); jffs2_clear_inode(inode);
...@@ -744,7 +744,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de ...@@ -744,7 +744,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, ALLOC_NORMAL);
if (IS_ERR(fd)) { if (IS_ERR(fd)) {
/* dirent failed to write. Delete the inode normally /* dirent failed to write. Delete the inode normally
......
...@@ -230,6 +230,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, ...@@ -230,6 +230,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
at the end of the linked list. Stash it and continue at the end of the linked list. Stash it and continue
from the beginning of the list */ from the beginning of the list */
ic = (struct jffs2_inode_cache *)(*prev); ic = (struct jffs2_inode_cache *)(*prev);
BUG_ON(ic->class != RAWNODE_CLASS_INODE_CACHE);
prev = &ic->nodes; prev = &ic->nodes;
continue; continue;
} }
...@@ -410,10 +411,9 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb ...@@ -410,10 +411,9 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
/* Everything else got zeroed before the erase */ /* Everything else got zeroed before the erase */
jeb->free_size = c->sector_size; jeb->free_size = c->sector_size;
marker_ref->next_in_ino = NULL;
marker_ref->flash_offset = jeb->offset | REF_NORMAL; marker_ref->flash_offset = jeb->offset | REF_NORMAL;
jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size); jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size, NULL);
} }
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
......
...@@ -134,13 +134,13 @@ static int jffs2_prepare_write (struct file *filp, struct page *pg, ...@@ -134,13 +134,13 @@ static int jffs2_prepare_write (struct file *filp, struct page *pg,
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
struct jffs2_raw_inode ri; struct jffs2_raw_inode ri;
struct jffs2_full_dnode *fn; struct jffs2_full_dnode *fn;
uint32_t phys_ofs, alloc_len; uint32_t alloc_len;
D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
(unsigned int)inode->i_size, pageofs)); (unsigned int)inode->i_size, pageofs));
ret = jffs2_reserve_space(c, sizeof(ri), &phys_ofs, &alloc_len, ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
if (ret) if (ret)
return ret; return ret;
...@@ -166,7 +166,7 @@ static int jffs2_prepare_write (struct file *filp, struct page *pg, ...@@ -166,7 +166,7 @@ static int jffs2_prepare_write (struct file *filp, struct page *pg,
ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
ri.data_crc = cpu_to_je32(0); ri.data_crc = cpu_to_je32(0);
fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_NORMAL); fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_NORMAL);
if (IS_ERR(fn)) { if (IS_ERR(fn)) {
ret = PTR_ERR(fn); ret = PTR_ERR(fn);
......
...@@ -37,7 +37,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) ...@@ -37,7 +37,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
unsigned char *mdata = NULL; unsigned char *mdata = NULL;
int mdatalen = 0; int mdatalen = 0;
unsigned int ivalid; unsigned int ivalid;
uint32_t phys_ofs, alloclen; uint32_t alloclen;
int ret; int ret;
D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino));
ret = inode_change_ok(inode, iattr); ret = inode_change_ok(inode, iattr);
...@@ -79,8 +79,8 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) ...@@ -79,8 +79,8 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
return -ENOMEM; return -ENOMEM;
} }
ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &phys_ofs, &alloclen, ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
if (ret) { if (ret) {
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
if (S_ISLNK(inode->i_mode & S_IFMT)) if (S_ISLNK(inode->i_mode & S_IFMT))
...@@ -131,7 +131,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) ...@@ -131,7 +131,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
else else
ri->data_crc = cpu_to_je32(0); ri->data_crc = cpu_to_je32(0);
new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, ALLOC_NORMAL); new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, ALLOC_NORMAL);
if (S_ISLNK(inode->i_mode)) if (S_ISLNK(inode->i_mode))
kfree(mdata); kfree(mdata);
...@@ -664,13 +664,6 @@ static int jffs2_flash_setup(struct jffs2_sb_info *c) { ...@@ -664,13 +664,6 @@ static int jffs2_flash_setup(struct jffs2_sb_info *c) {
return ret; return ret;
} }
/* add setups for other bizarre flashes here... */
if (jffs2_nor_ecc(c)) {
ret = jffs2_nor_ecc_flash_setup(c);
if (ret)
return ret;
}
/* and Dataflash */ /* and Dataflash */
if (jffs2_dataflash(c)) { if (jffs2_dataflash(c)) {
ret = jffs2_dataflash_setup(c); ret = jffs2_dataflash_setup(c);
...@@ -694,11 +687,6 @@ void jffs2_flash_cleanup(struct jffs2_sb_info *c) { ...@@ -694,11 +687,6 @@ void jffs2_flash_cleanup(struct jffs2_sb_info *c) {
jffs2_nand_flash_cleanup(c); jffs2_nand_flash_cleanup(c);
} }
/* add cleanups for other bizarre flashes here... */
if (jffs2_nor_ecc(c)) {
jffs2_nor_ecc_flash_cleanup(c);
}
/* and DataFlash */ /* and DataFlash */
if (jffs2_dataflash(c)) { if (jffs2_dataflash(c)) {
jffs2_dataflash_cleanup(c); jffs2_dataflash_cleanup(c);
......
...@@ -545,7 +545,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -545,7 +545,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
if (ic && alloclen > sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN) if (ic && alloclen > sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN)
alloclen = sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN; alloclen = sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN;
ret = jffs2_reserve_space_gc(c, alloclen, &phys_ofs, &alloclen, rawlen); ret = jffs2_reserve_space_gc(c, alloclen, &alloclen, rawlen);
/* 'rawlen' is not the exact summary size; it is only an upper estimation */ /* 'rawlen' is not the exact summary size; it is only an upper estimation */
if (ret) if (ret)
...@@ -626,19 +626,16 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -626,19 +626,16 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
/* OK, all the CRCs are good; this node can just be copied as-is. */ /* OK, all the CRCs are good; this node can just be copied as-is. */
retry: retry:
nraw->flash_offset = phys_ofs; nraw->flash_offset = phys_ofs = write_ofs(c);
ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node);
if (ret || (retlen != rawlen)) { if (ret || (retlen != rawlen)) {
printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n",
rawlen, phys_ofs, ret, retlen); rawlen, nraw->flash_offset, ret, retlen);
if (retlen) { if (retlen) {
/* Doesn't belong to any inode */
nraw->next_in_ino = NULL;
nraw->flash_offset |= REF_OBSOLETE; nraw->flash_offset |= REF_OBSOLETE;
jffs2_add_physical_node_ref(c, nraw, rawlen); jffs2_add_physical_node_ref(c, nraw, rawlen, NULL);
jffs2_mark_node_obsolete(c, nraw); jffs2_mark_node_obsolete(c, nraw);
} else { } else {
printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset); 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,7 +653,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
jffs2_dbg_acct_sanity_check(c,jeb); jffs2_dbg_acct_sanity_check(c,jeb);
jffs2_dbg_acct_paranoia_check(c, jeb); jffs2_dbg_acct_paranoia_check(c, jeb);
ret = jffs2_reserve_space_gc(c, rawlen, &phys_ofs, &dummy, rawlen); ret = jffs2_reserve_space_gc(c, rawlen, &dummy, rawlen);
/* this is not the exact summary size of it, /* this is not the exact summary size of it,
it is only an upper estimation */ it is only an upper estimation */
...@@ -678,18 +675,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -678,18 +675,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
goto out_node; goto out_node;
} }
nraw->flash_offset |= REF_PRISTINE; nraw->flash_offset |= REF_PRISTINE;
jffs2_add_physical_node_ref(c, nraw, rawlen); jffs2_add_physical_node_ref(c, nraw, rawlen, ic);
if (ic) {
/* Link into per-inode list. This is safe because of the ic
state being INO_STATE_GC. Note that if we're doing this
for an inode which is in-core, the 'nraw' pointer is then
going to be fetched from ic->nodes by our caller. */
spin_lock(&c->erase_completion_lock);
nraw->next_in_ino = ic->nodes;
ic->nodes = nraw;
spin_unlock(&c->erase_completion_lock);
}
jffs2_mark_node_obsolete(c, raw); jffs2_mark_node_obsolete(c, raw);
D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw)));
...@@ -709,7 +696,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ ...@@ -709,7 +696,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
struct jffs2_node_frag *last_frag; struct jffs2_node_frag *last_frag;
union jffs2_device_node dev; union jffs2_device_node dev;
char *mdata = NULL, mdatalen = 0; char *mdata = NULL, mdatalen = 0;
uint32_t alloclen, phys_ofs, ilen; uint32_t alloclen, ilen;
int ret; int ret;
if (S_ISBLK(JFFS2_F_I_MODE(f)) || 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,7 +722,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
} }
ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &phys_ofs, &alloclen, ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &alloclen,
JFFS2_SUMMARY_INODE_SIZE); JFFS2_SUMMARY_INODE_SIZE);
if (ret) { if (ret) {
printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", 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,7 +760,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
ri.data_crc = cpu_to_je32(crc32(0, mdata, mdatalen)); ri.data_crc = cpu_to_je32(crc32(0, mdata, mdatalen));
new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, phys_ofs, ALLOC_GC); new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, ALLOC_GC);
if (IS_ERR(new_fn)) { if (IS_ERR(new_fn)) {
printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); 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,7 +781,7 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er
{ {
struct jffs2_full_dirent *new_fd; struct jffs2_full_dirent *new_fd;
struct jffs2_raw_dirent rd; struct jffs2_raw_dirent rd;
uint32_t alloclen, phys_ofs; uint32_t alloclen;
int ret; int ret;
rd.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 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,14 +803,14 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er
rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8)); rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8));
rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize)); rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize));
ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &phys_ofs, &alloclen, ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &alloclen,
JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize));
if (ret) { if (ret) {
printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n",
sizeof(rd)+rd.nsize, ret); sizeof(rd)+rd.nsize, ret);
return ret; return ret;
} }
new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, phys_ofs, ALLOC_GC); new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, ALLOC_GC);
if (IS_ERR(new_fd)) { if (IS_ERR(new_fd)) {
printk(KERN_WARNING "jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd)); 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,7 +938,7 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras
struct jffs2_raw_inode ri; struct jffs2_raw_inode ri;
struct jffs2_node_frag *frag; struct jffs2_node_frag *frag;
struct jffs2_full_dnode *new_fn; struct jffs2_full_dnode *new_fn;
uint32_t alloclen, phys_ofs, ilen; uint32_t alloclen, ilen;
int ret; int ret;
D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", 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,14 +1017,14 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras
ri.data_crc = cpu_to_je32(0); ri.data_crc = cpu_to_je32(0);
ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
ret = jffs2_reserve_space_gc(c, sizeof(ri), &phys_ofs, &alloclen, ret = jffs2_reserve_space_gc(c, sizeof(ri), &alloclen,
JFFS2_SUMMARY_INODE_SIZE); JFFS2_SUMMARY_INODE_SIZE);
if (ret) { if (ret) {
printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n",
sizeof(ri), ret); sizeof(ri), ret);
return ret; return ret;
} }
new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_GC); new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_GC);
if (IS_ERR(new_fn)) { if (IS_ERR(new_fn)) {
printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn)); 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,7 +1086,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
{ {
struct jffs2_full_dnode *new_fn; struct jffs2_full_dnode *new_fn;
struct jffs2_raw_inode ri; struct jffs2_raw_inode ri;
uint32_t alloclen, phys_ofs, offset, orig_end, orig_start; uint32_t alloclen, offset, orig_end, orig_start;
int ret = 0; int ret = 0;
unsigned char *comprbuf = NULL, *writebuf; unsigned char *comprbuf = NULL, *writebuf;
unsigned long pg; unsigned long pg;
...@@ -1256,7 +1243,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era ...@@ -1256,7 +1243,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
uint32_t cdatalen; uint32_t cdatalen;
uint16_t comprtype = JFFS2_COMPR_NONE; uint16_t comprtype = JFFS2_COMPR_NONE;
ret = jffs2_reserve_space_gc(c, sizeof(ri) + JFFS2_MIN_DATA_LEN, &phys_ofs, ret = jffs2_reserve_space_gc(c, sizeof(ri) + JFFS2_MIN_DATA_LEN,
&alloclen, JFFS2_SUMMARY_INODE_SIZE); &alloclen, JFFS2_SUMMARY_INODE_SIZE);
if (ret) { if (ret) {
...@@ -1293,7 +1280,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era ...@@ -1293,7 +1280,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen)); ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen));
new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, phys_ofs, ALLOC_GC); new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, ALLOC_GC);
jffs2_free_comprbuf(comprbuf, writebuf); jffs2_free_comprbuf(comprbuf, writebuf);
......
...@@ -1048,7 +1048,8 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c) ...@@ -1048,7 +1048,8 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
} }
void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
struct jffs2_raw_node_ref *ref, uint32_t len) struct jffs2_raw_node_ref *ref, uint32_t len,
struct jffs2_inode_cache *ic)
{ {
if (!jeb->first_node) if (!jeb->first_node)
jeb->first_node = ref; jeb->first_node = ref;
...@@ -1065,6 +1066,13 @@ void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, ...@@ -1065,6 +1066,13 @@ void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
} }
jeb->last_node = ref; jeb->last_node = ref;
if (ic) {
ref->next_in_ino = ic->nodes;
ic->nodes = ref;
} else {
ref->next_in_ino = NULL;
}
switch(ref_flags(ref)) { switch(ref_flags(ref)) {
case REF_UNCHECKED: case REF_UNCHECKED:
c->unchecked_size += len; c->unchecked_size += len;
...@@ -1120,12 +1128,11 @@ int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb ...@@ -1120,12 +1128,11 @@ int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size; ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size;
ref->flash_offset |= REF_OBSOLETE; ref->flash_offset |= REF_OBSOLETE;
ref->next_in_ino = 0;
#ifdef TEST_TOTLEN #ifdef TEST_TOTLEN
ref->__totlen = size; ref->__totlen = size;
#endif #endif
jffs2_link_node_ref(c, jeb, ref, size); jffs2_link_node_ref(c, jeb, ref, size, NULL);
} }
return 0; return 0;
......
...@@ -77,9 +77,9 @@ ...@@ -77,9 +77,9 @@
struct jffs2_raw_node_ref struct jffs2_raw_node_ref
{ {
struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref
for this inode. If this is the last, it points to the inode_cache for this object. If this _is_ the last, it points to the inode_cache,
for this inode instead. The inode_cache will have NULL in the first xattr_ref or xattr_datum instead. The common part of those structures
word so you know when you've got there :) */ has NULL in the first word. See jffs2_raw_ref_to_ic() below */
struct jffs2_raw_node_ref *next_phys; struct jffs2_raw_node_ref *next_phys;
uint32_t flash_offset; uint32_t flash_offset;
#define TEST_TOTLEN #define TEST_TOTLEN
...@@ -88,6 +88,18 @@ struct jffs2_raw_node_ref ...@@ -88,6 +88,18 @@ struct jffs2_raw_node_ref
#endif #endif
}; };
static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw)
{
while(raw->next_in_ino) {
raw = raw->next_in_ino;
}
/* NB. This can be a jffs2_xattr_datum or jffs2_xattr_ref and
not actually a jffs2_inode_cache. Check ->class */
return ((struct jffs2_inode_cache *)raw);
}
/* flash_offset & 3 always has to be zero, because nodes are /* flash_offset & 3 always has to be zero, because nodes are
always aligned at 4 bytes. So we have a couple of extra bits always aligned at 4 bytes. So we have a couple of extra bits
to play with, which indicate the node's status; see below: */ to play with, which indicate the node's status; see below: */
...@@ -113,20 +125,27 @@ struct jffs2_raw_node_ref ...@@ -113,20 +125,27 @@ struct jffs2_raw_node_ref
a pointer to the first physical node which is part of this inode, too. a pointer to the first physical node which is part of this inode, too.
*/ */
struct jffs2_inode_cache { struct jffs2_inode_cache {
/* First part of structure is shared with other objects which
can terminate the raw node refs' next_in_ino list -- which
currently struct jffs2_xattr_datum and struct jffs2_xattr_ref. */
struct jffs2_full_dirent *scan_dents; /* Used during scan to hold struct jffs2_full_dirent *scan_dents; /* Used during scan to hold
temporary lists of dirents, and later must be set to temporary lists of dirents, and later must be set to
NULL to mark the end of the raw_node_ref->next_in_ino NULL to mark the end of the raw_node_ref->next_in_ino
chain. */ chain. */
u8 class; /* It's used for identification */
u8 flags;
uint16_t state;
struct jffs2_inode_cache *next;
struct jffs2_raw_node_ref *nodes; struct jffs2_raw_node_ref *nodes;
uint8_t class; /* It's used for identification */
/* end of shared structure */
uint8_t flags;
uint16_t state;
uint32_t ino; uint32_t ino;
int nlink; struct jffs2_inode_cache *next;
#ifdef CONFIG_JFFS2_FS_XATTR #ifdef CONFIG_JFFS2_FS_XATTR
struct jffs2_xattr_ref *xref; struct jffs2_xattr_ref *xref;
#endif #endif
int nlink;
}; };
/* Inode states for 'state' above. We need the 'GC' state to prevent /* Inode states for 'state' above. We need the 'GC' state to prevent
...@@ -148,6 +167,8 @@ struct jffs2_inode_cache { ...@@ -148,6 +167,8 @@ struct jffs2_inode_cache {
#define INOCACHE_HASHSIZE 128 #define INOCACHE_HASHSIZE 128
#define write_ofs(c) ((c)->nextblock->offset + (c)->sector_size - (c)->nextblock->free_size)
/* /*
Larger representation of a raw node, kept in-core only when the Larger representation of a raw node, kept in-core only when the
struct inode for this particular ino is instantiated. 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,15 +271,6 @@ static inline int jffs2_encode_dev(union jffs2_device_node *jdev, dev_t rdev)
} }
} }
static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw)
{
while(raw->next_in_ino) {
raw = raw->next_in_ino;
}
return ((struct jffs2_inode_cache *)raw);
}
static inline struct jffs2_node_frag *frag_first(struct rb_root *root) static inline struct jffs2_node_frag *frag_first(struct rb_root *root)
{ {
struct rb_node *node = root->rb_node; 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 ...@@ -307,32 +319,43 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size); void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size);
int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn); int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn);
void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
struct jffs2_raw_node_ref *ref, uint32_t len); struct jffs2_raw_node_ref *ref, uint32_t len,
struct jffs2_inode_cache *ic);
extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c, extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb, struct jffs2_eraseblock *jeb,
struct jffs2_raw_node_ref *ref); struct jffs2_raw_node_ref *ref);
/* nodemgmt.c */ /* nodemgmt.c */
int jffs2_thread_should_wake(struct jffs2_sb_info *c); int jffs2_thread_should_wake(struct jffs2_sb_info *c);
int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
uint32_t *len, int prio, uint32_t sumsize); uint32_t *len, int prio, uint32_t sumsize);
int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
uint32_t *len, uint32_t sumsize); uint32_t *len, uint32_t sumsize);
int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len); int jffs2_add_physical_node_ref(struct jffs2_sb_info *c,
struct jffs2_raw_node_ref *new,
uint32_t len,
struct jffs2_inode_cache *ic);
void jffs2_complete_reservation(struct jffs2_sb_info *c); void jffs2_complete_reservation(struct jffs2_sb_info *c);
void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw);
/* write.c */ /* write.c */
int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri); int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri);
struct 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); struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
struct 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); struct jffs2_raw_inode *ri, const unsigned char *data,
uint32_t datalen, int alloc_mode);
struct 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, int alloc_mode);
int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
struct jffs2_raw_inode *ri, unsigned char *buf, struct jffs2_raw_inode *ri, unsigned char *buf,
uint32_t offset, uint32_t writelen, uint32_t *retlen); uint32_t offset, uint32_t writelen, uint32_t *retlen);
int 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); int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f,
int 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); struct jffs2_raw_inode *ri, const char *name, int namelen);
int 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); int 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);
int 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);
/* readinode.c */ /* readinode.c */
......
...@@ -23,13 +23,12 @@ ...@@ -23,13 +23,12 @@
* jffs2_reserve_space - request physical space to write nodes to flash * jffs2_reserve_space - request physical space to write nodes to flash
* @c: superblock info * @c: superblock info
* @minsize: Minimum acceptable size of allocation * @minsize: Minimum acceptable size of allocation
* @ofs: Returned value of node offset
* @len: Returned value of allocation length * @len: Returned value of allocation length
* @prio: Allocation type - ALLOC_{NORMAL,DELETION} * @prio: Allocation type - ALLOC_{NORMAL,DELETION}
* *
* Requests a block of physical space on the flash. Returns zero for success * Requests a block of physical space on the flash. Returns zero for success
* and puts 'ofs' and 'len' into the appriopriate place, or returns -ENOSPC * and puts 'len' into the appropriate place, or returns -ENOSPC or other
* or other error if appropriate. * error if appropriate. Doesn't return len since that's
* *
* If it returns zero, jffs2_reserve_space() also downs the per-filesystem * If it returns zero, jffs2_reserve_space() also downs the per-filesystem
* allocation semaphore, to prevent more than one allocation from being * allocation semaphore, to prevent more than one allocation from being
...@@ -40,9 +39,9 @@ ...@@ -40,9 +39,9 @@
*/ */
static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
uint32_t *ofs, uint32_t *len, uint32_t sumsize); uint32_t *len, uint32_t sumsize);
int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
uint32_t *len, int prio, uint32_t sumsize) uint32_t *len, int prio, uint32_t sumsize)
{ {
int ret = -EAGAIN; int ret = -EAGAIN;
...@@ -132,7 +131,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs ...@@ -132,7 +131,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
} }
ret = jffs2_do_reserve_space(c, minsize, ofs, len, sumsize); ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
if (ret) { if (ret) {
D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret)); D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret));
} }
...@@ -143,8 +142,8 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs ...@@ -143,8 +142,8 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs
return ret; return ret;
} }
int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
uint32_t *len, uint32_t sumsize) uint32_t *len, uint32_t sumsize)
{ {
int ret = -EAGAIN; int ret = -EAGAIN;
minsize = PAD(minsize); minsize = PAD(minsize);
...@@ -153,7 +152,7 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t * ...@@ -153,7 +152,7 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
while(ret == -EAGAIN) { while(ret == -EAGAIN) {
ret = jffs2_do_reserve_space(c, minsize, ofs, len, sumsize); ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
if (ret) { if (ret) {
D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret));
} }
...@@ -259,10 +258,11 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) ...@@ -259,10 +258,11 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c)
} }
/* Called with alloc sem _and_ erase_completion_lock */ /* Called with alloc sem _and_ erase_completion_lock */
static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len, uint32_t sumsize) static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
uint32_t *len, uint32_t sumsize)
{ {
struct jffs2_eraseblock *jeb = c->nextblock; struct jffs2_eraseblock *jeb = c->nextblock;
uint32_t reserved_size; /* for summary information at the end of the jeb */ uint32_t reserved_size; /* for summary information at the end of the jeb */
int ret; int ret;
restart: restart:
...@@ -349,7 +349,6 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin ...@@ -349,7 +349,6 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
} }
/* OK, jeb (==c->nextblock) is now pointing at a block which definitely has /* OK, jeb (==c->nextblock) is now pointing at a block which definitely has
enough space */ enough space */
*ofs = jeb->offset + (c->sector_size - jeb->free_size);
*len = jeb->free_size - reserved_size; *len = jeb->free_size - reserved_size;
if (c->cleanmarker_size && jeb->used_size == c->cleanmarker_size && 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,7 +364,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
} }
D1(printk(KERN_DEBUG "jffs2_do_reserve_space(): Giving 0x%x bytes at 0x%x\n", *len, *ofs)); D1(printk(KERN_DEBUG "jffs2_do_reserve_space(): Giving 0x%x bytes at 0x%x\n",
*len, jeb->offset + (c->sector_size - jeb->free_size)));
return 0; return 0;
} }
...@@ -381,7 +381,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin ...@@ -381,7 +381,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
* Must be called with the alloc_sem held. * Must be called with the alloc_sem held.
*/ */
int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len) int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new,
uint32_t len, struct jffs2_inode_cache *ic)
{ {
struct jffs2_eraseblock *jeb; struct jffs2_eraseblock *jeb;
...@@ -403,7 +404,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r ...@@ -403,7 +404,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r
#endif #endif
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
jffs2_link_node_ref(c, jeb, new, len); jffs2_link_node_ref(c, jeb, new, len, ic);
if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) {
/* If it lives on the dirty_list, jffs2_reserve_space will put it there */ /* 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,6 +661,10 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
ic = jffs2_raw_ref_to_ic(ref); ic = jffs2_raw_ref_to_ic(ref);
/* It seems we should never call jffs2_mark_node_obsolete() for
XATTR nodes.... yet. Make sure we notice if/when we change
that :) */
BUG_ON(ic->class != RAWNODE_CLASS_INODE_CACHE);
for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino)) for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino))
; ;
......
...@@ -92,11 +92,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) ...@@ -92,11 +92,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
#define jffs2_flash_writev(a,b,c,d,e,f) jffs2_flash_direct_writev(a,b,c,d,e) #define jffs2_flash_writev(a,b,c,d,e,f) jffs2_flash_direct_writev(a,b,c,d,e)
#define jffs2_wbuf_timeout NULL #define jffs2_wbuf_timeout NULL
#define jffs2_wbuf_process NULL #define jffs2_wbuf_process NULL
#define jffs2_nor_ecc(c) (0)
#define jffs2_dataflash(c) (0) #define jffs2_dataflash(c) (0)
#define jffs2_nor_wbuf_flash(c) (0)
#define jffs2_nor_ecc_flash_setup(c) (0)
#define jffs2_nor_ecc_flash_cleanup(c) do {} while (0)
#define jffs2_dataflash_setup(c) (0) #define jffs2_dataflash_setup(c) (0)
#define jffs2_dataflash_cleanup(c) do {} while (0) #define jffs2_dataflash_cleanup(c) do {} while (0)
#define jffs2_nor_wbuf_flash_setup(c) (0) #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,9 +105,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
#ifdef CONFIG_JFFS2_SUMMARY #ifdef CONFIG_JFFS2_SUMMARY
#define jffs2_can_mark_obsolete(c) (0) #define jffs2_can_mark_obsolete(c) (0)
#else #else
#define jffs2_can_mark_obsolete(c) \ #define jffs2_can_mark_obsolete(c) (c->mtd->flags & (MTD_BIT_WRITEABLE))
((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & (MTD_ECC|MTD_PROGRAM_REGIONS))) || \
c->mtd->type == MTD_RAM)
#endif #endif
#define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH) #define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH)
...@@ -135,15 +129,11 @@ int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c); ...@@ -135,15 +129,11 @@ int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c);
int jffs2_nand_flash_setup(struct jffs2_sb_info *c); int jffs2_nand_flash_setup(struct jffs2_sb_info *c);
void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c); void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c);
#define jffs2_nor_ecc(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_ECC))
int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c);
void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c);
#define jffs2_dataflash(c) (c->mtd->type == MTD_DATAFLASH) #define jffs2_dataflash(c) (c->mtd->type == MTD_DATAFLASH)
int jffs2_dataflash_setup(struct jffs2_sb_info *c); int jffs2_dataflash_setup(struct jffs2_sb_info *c);
void jffs2_dataflash_cleanup(struct jffs2_sb_info *c); void jffs2_dataflash_cleanup(struct jffs2_sb_info *c);
#define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_PROGRAM_REGIONS)) #define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && ! (c->mtd->flags & MTD_BIT_WRITEABLE))
int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c); int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c);
void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c); void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c);
......
...@@ -361,9 +361,9 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc ...@@ -361,9 +361,9 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
xd->node = raw; xd->node = raw;
raw->flash_offset = ofs | REF_PRISTINE; raw->flash_offset = ofs | REF_PRISTINE;
raw->next_in_ino = (void *)xd;
jffs2_link_node_ref(c, jeb, raw, totlen); jffs2_link_node_ref(c, jeb, raw, totlen, NULL);
/* FIXME */ raw->next_in_ino = (void *)xd;
if (jffs2_sum_active()) if (jffs2_sum_active())
jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); 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,9 +425,9 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
c->xref_temp = ref; c->xref_temp = ref;
raw->flash_offset = ofs | REF_PRISTINE; raw->flash_offset = ofs | REF_PRISTINE;
raw->next_in_ino = (void *)ref;
jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rr->totlen))); jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rr->totlen)), NULL);
/* FIXME */ raw->next_in_ino = (void *)ref;
if (jffs2_sum_active()) if (jffs2_sum_active())
jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset); jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset);
...@@ -844,10 +844,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -844,10 +844,9 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
printk(KERN_NOTICE "Failed to allocate node ref for clean marker\n"); printk(KERN_NOTICE "Failed to allocate node ref for clean marker\n");
return -ENOMEM; return -ENOMEM;
} }
marker_ref->next_in_ino = NULL;
marker_ref->flash_offset = ofs | REF_NORMAL; marker_ref->flash_offset = ofs | REF_NORMAL;
jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size); jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size, NULL);
ofs += PAD(c->cleanmarker_size); ofs += PAD(c->cleanmarker_size);
} }
...@@ -892,8 +891,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo ...@@ -892,8 +891,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
if (!ref) if (!ref)
return -ENOMEM; return -ENOMEM;
ref->flash_offset = ofs | REF_PRISTINE; ref->flash_offset = ofs | REF_PRISTINE;
ref->next_in_ino = 0; jffs2_link_node_ref(c, jeb, ref, PAD(je32_to_cpu(node->totlen)), NULL);
jffs2_link_node_ref(c, jeb, ref, PAD(je32_to_cpu(node->totlen)));
/* We can't summarise nodes we don't grok */ /* We can't summarise nodes we don't grok */
jffs2_sum_disable_collecting(s); jffs2_sum_disable_collecting(s);
...@@ -1004,10 +1002,7 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc ...@@ -1004,10 +1002,7 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
raw->flash_offset = ofs | REF_UNCHECKED; raw->flash_offset = ofs | REF_UNCHECKED;
raw->next_in_ino = ic->nodes; jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(ri->totlen)), ic);
ic->nodes = raw;
jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(ri->totlen)));
D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n",
je32_to_cpu(ri->ino), je32_to_cpu(ri->version), 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,10 +1077,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
} }
raw->flash_offset = ofs | REF_PRISTINE; raw->flash_offset = ofs | REF_PRISTINE;
raw->next_in_ino = ic->nodes; jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rd->totlen)), ic);
ic->nodes = raw;
jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rd->totlen)));
fd->raw = raw; fd->raw = raw;
fd->next = NULL; fd->next = NULL;
......
...@@ -430,10 +430,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras ...@@ -430,10 +430,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
raw->flash_offset |= REF_UNCHECKED; raw->flash_offset |= REF_UNCHECKED;
raw->next_in_ino = ic->nodes; jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spi->totlen)), ic);
ic->nodes = raw;
jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spi->totlen)));
*pseudo_random += je32_to_cpu(spi->version); *pseudo_random += je32_to_cpu(spi->version);
...@@ -473,10 +470,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras ...@@ -473,10 +470,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
} }
raw->flash_offset |= REF_PRISTINE; raw->flash_offset |= REF_PRISTINE;
raw->next_in_ino = ic->nodes; jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spd->totlen)), ic);
ic->nodes = raw;
jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spd->totlen)));
fd->raw = raw; fd->raw = raw;
fd->next = NULL; fd->next = NULL;
...@@ -525,9 +519,9 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras ...@@ -525,9 +519,9 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
xd->node = raw; xd->node = raw;
raw->flash_offset |= REF_UNCHECKED; raw->flash_offset |= REF_UNCHECKED;
raw->next_in_ino = (void *)xd;
jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spx->totlen))); jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spx->totlen)), NULL);
/* FIXME */ raw->next_in_ino = (void *)xd;
*pseudo_random += je32_to_cpu(spx->xid); *pseudo_random += je32_to_cpu(spx->xid);
sp += JFFS2_SUMMARY_XATTR_SIZE; 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,9 +555,9 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
c->xref_temp = ref; c->xref_temp = ref;
raw->flash_offset |= REF_UNCHECKED; raw->flash_offset |= REF_UNCHECKED;
raw->next_in_ino = (void *)ref;
jffs2_link_node_ref(c, jeb, raw, PAD(sizeof(struct jffs2_raw_xref))); jffs2_link_node_ref(c, jeb, raw, PAD(sizeof(struct jffs2_raw_xref)), NULL);
/* FIXME */ raw->next_in_ino = (void *)ref;
*pseudo_random += raw->flash_offset; *pseudo_random += raw->flash_offset;
sp += JFFS2_SUMMARY_XREF_SIZE; sp += JFFS2_SUMMARY_XREF_SIZE;
...@@ -664,9 +658,8 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb ...@@ -664,9 +658,8 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
} }
marker_ref->flash_offset = jeb->offset | REF_NORMAL; marker_ref->flash_offset = jeb->offset | REF_NORMAL;
marker_ref->next_in_ino = NULL;
jffs2_link_node_ref(c, jeb, marker_ref, je32_to_cpu(summary->cln_mkr)); jffs2_link_node_ref(c, jeb, marker_ref, je32_to_cpu(summary->cln_mkr), NULL);
} }
} }
...@@ -686,10 +679,9 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb ...@@ -686,10 +679,9 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
return -ENOMEM; return -ENOMEM;
} }
cache_ref->next_in_ino = NULL;
cache_ref->flash_offset |= REF_NORMAL; cache_ref->flash_offset |= REF_NORMAL;
jffs2_link_node_ref(c, jeb, cache_ref, sumsize); jffs2_link_node_ref(c, jeb, cache_ref, sumsize, NULL);
if (unlikely(jeb->free_size)) { if (unlikely(jeb->free_size)) {
JFFS2_WARNING("Free size 0x%x bytes in eraseblock @0x%08x with summary?\n", 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,9 +841,8 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size; ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size;
ref->flash_offset |= REF_OBSOLETE; ref->flash_offset |= REF_OBSOLETE;
ref->next_in_ino = 0;
jffs2_link_node_ref(c, jeb, ref, c->sector_size - jeb->free_size); jffs2_link_node_ref(c, jeb, ref, c->sector_size - jeb->free_size, NULL);
} }
c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
...@@ -909,11 +900,10 @@ int jffs2_sum_write_sumnode(struct jffs2_sb_info *c) ...@@ -909,11 +900,10 @@ int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
return -ENOMEM; return -ENOMEM;
} }
summary_ref->next_in_ino = NULL;
summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL; summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL;
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
jffs2_link_node_ref(c, jeb, summary_ref, infosize); jffs2_link_node_ref(c, jeb, summary_ref, infosize, NULL);
return 0; return 0;
} }
...@@ -265,12 +265,14 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) ...@@ -265,12 +265,14 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
/* ... and get an allocation of space from a shiny new block instead */ /* ... and get an allocation of space from a shiny new block instead */
ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len, JFFS2_SUMMARY_NOSUM_SIZE); ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE);
if (ret) { if (ret) {
printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n");
kfree(buf); kfree(buf);
return; return;
} }
ofs = write_ofs(c);
if (end-start >= c->wbuf_pagesize) { if (end-start >= c->wbuf_pagesize) {
/* Need to do another write immediately, but it's possible /* Need to do another write immediately, but it's possible
that this is just because the wbuf itself is completely 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,9 +314,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
return; return;
raw2->flash_offset = ofs | REF_OBSOLETE; raw2->flash_offset = ofs | REF_OBSOLETE;
raw2->next_in_ino = NULL;
jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw)); jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw), NULL);
} }
return; return;
} }
...@@ -507,11 +508,10 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) ...@@ -507,11 +508,10 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
return -ENOMEM; return -ENOMEM;
ref->flash_offset = c->wbuf_ofs + c->wbuf_len; ref->flash_offset = c->wbuf_ofs + c->wbuf_len;
ref->flash_offset |= REF_OBSOLETE; ref->flash_offset |= REF_OBSOLETE;
ref->next_in_ino = NULL;
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
jffs2_link_node_ref(c, jeb, ref, waste); jffs2_link_node_ref(c, jeb, ref, waste, NULL);
/* FIXME: that made it count as dirty. Convert to wasted */ /* FIXME: that made it count as dirty. Convert to wasted */
jeb->dirty_size -= waste; jeb->dirty_size -= waste;
c->dirty_size -= waste; c->dirty_size -= waste;
...@@ -649,19 +649,6 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, ...@@ -649,19 +649,6 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
memset(c->wbuf,0xff,c->wbuf_pagesize); memset(c->wbuf,0xff,c->wbuf_pagesize);
} }
/*
* Fixup the wbuf if we are moving to a new eraseblock. The
* checks below fail for ECC'd NOR because cleanmarker == 16,
* so a block starts at xxx0010.
*/
if (jffs2_nor_ecc(c)) {
if (((c->wbuf_ofs % c->sector_size) == 0) && !c->wbuf_len) {
c->wbuf_ofs = PAGE_DIV(to);
c->wbuf_len = PAGE_MOD(to);
memset(c->wbuf,0xff,c->wbuf_pagesize);
}
}
/* /*
* Sanity checks on target address. It's permitted to write * Sanity checks on target address. It's permitted to write
* at PAD(c->wbuf_len+c->wbuf_ofs), and it's permitted to * at PAD(c->wbuf_len+c->wbuf_ofs), and it's permitted to
...@@ -1107,7 +1094,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) ...@@ -1107,7 +1094,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
/* Initialise write buffer */ /* Initialise write buffer */
init_rwsem(&c->wbuf_sem); init_rwsem(&c->wbuf_sem);
c->wbuf_pagesize = c->mtd->oobblock; c->wbuf_pagesize = c->mtd->writesize;
c->wbuf_ofs = 0xFFFFFFFF; c->wbuf_ofs = 0xFFFFFFFF;
c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
...@@ -1178,33 +1165,14 @@ void jffs2_dataflash_cleanup(struct jffs2_sb_info *c) { ...@@ -1178,33 +1165,14 @@ void jffs2_dataflash_cleanup(struct jffs2_sb_info *c) {
kfree(c->wbuf); kfree(c->wbuf);
} }
int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c) {
/* Cleanmarker is actually larger on the flashes */
c->cleanmarker_size = 16;
/* Initialize write buffer */
init_rwsem(&c->wbuf_sem);
c->wbuf_pagesize = c->mtd->eccsize;
c->wbuf_ofs = 0xFFFFFFFF;
c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
if (!c->wbuf)
return -ENOMEM;
return 0;
}
void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) {
kfree(c->wbuf);
}
int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) { int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) {
/* Cleanmarker currently occupies a whole programming region */ /* Cleanmarker currently occupies whole programming regions,
c->cleanmarker_size = MTD_PROGREGION_SIZE(c->mtd); * either one or 2 for 8Byte STMicro flashes. */
c->cleanmarker_size = max(16u, c->mtd->writesize);
/* Initialize write buffer */ /* Initialize write buffer */
init_rwsem(&c->wbuf_sem); init_rwsem(&c->wbuf_sem);
c->wbuf_pagesize = MTD_PROGREGION_SIZE(c->mtd); c->wbuf_pagesize = c->mtd->writesize;
c->wbuf_ofs = 0xFFFFFFFF; c->wbuf_ofs = 0xFFFFFFFF;
c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
......
This diff is collapsed.
...@@ -49,9 +49,9 @@ ...@@ -49,9 +49,9 @@
* is used to be as a wrapper of do_verify_xattr_datum() and do_load_xattr_datum(). * is used to be as a wrapper of do_verify_xattr_datum() and do_load_xattr_datum().
* If xd need to call do_verify_xattr_datum() at first, it's called before calling * If xd need to call do_verify_xattr_datum() at first, it's called before calling
* do_load_xattr_datum(). The meanings of return value is same as do_verify_xattr_datum(). * do_load_xattr_datum(). The meanings of return value is same as do_verify_xattr_datum().
* save_xattr_datum(c, xd, phys_ofs) * save_xattr_datum(c, xd)
* is used to write xdatum to medium. xd->version will be incremented. * is used to write xdatum to medium. xd->version will be incremented.
* create_xattr_datum(c, xprefix, xname, xvalue, xsize, phys_ofs) * create_xattr_datum(c, xprefix, xname, xvalue, xsize)
* is used to create new xdatum and write to medium. * is used to create new xdatum and write to medium.
* -------------------------------------------------- */ * -------------------------------------------------- */
...@@ -301,7 +301,7 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x ...@@ -301,7 +301,7 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
return rc; return rc;
} }
static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd, uint32_t phys_ofs) static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
{ {
/* must be called under down_write(xattr_sem) */ /* must be called under down_write(xattr_sem) */
struct jffs2_raw_xattr rx; 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,6 +309,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
struct kvec vecs[2]; struct kvec vecs[2];
uint32_t length; uint32_t length;
int rc, totlen; int rc, totlen;
uint32_t phys_ofs = write_ofs(c);
BUG_ON(!xd->xname); BUG_ON(!xd->xname);
...@@ -322,7 +323,6 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x ...@@ -322,7 +323,6 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
if (!raw) if (!raw)
return -ENOMEM; return -ENOMEM;
raw->flash_offset = phys_ofs; raw->flash_offset = phys_ofs;
raw->next_in_ino = (void *)xd;
/* Setup raw-xattr */ /* Setup raw-xattr */
rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 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,8 +345,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
rc = rc ? rc : -EIO; rc = rc ? rc : -EIO;
if (length) { if (length) {
raw->flash_offset |= REF_OBSOLETE; raw->flash_offset |= REF_OBSOLETE;
raw->next_in_ino = NULL; jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
jffs2_add_physical_node_ref(c, raw, PAD(totlen));
jffs2_mark_node_obsolete(c, raw); jffs2_mark_node_obsolete(c, raw);
} else { } else {
jffs2_free_raw_node_ref(raw); 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,7 +355,9 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
/* success */ /* success */
raw->flash_offset |= REF_PRISTINE; raw->flash_offset |= REF_PRISTINE;
jffs2_add_physical_node_ref(c, raw, PAD(totlen)); jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
/* FIXME */ raw->next_in_ino = (void *)xd;
if (xd->node) if (xd->node)
delete_xattr_datum_node(c, xd); delete_xattr_datum_node(c, xd);
xd->node = raw; xd->node = raw;
...@@ -369,8 +370,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x ...@@ -369,8 +370,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c, static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
int xprefix, const char *xname, int xprefix, const char *xname,
const char *xvalue, int xsize, const char *xvalue, int xsize)
uint32_t phys_ofs)
{ {
/* must be called under down_write(xattr_sem) */ /* must be called under down_write(xattr_sem) */
struct jffs2_xattr_datum *xd; struct jffs2_xattr_datum *xd;
...@@ -419,7 +419,7 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c, ...@@ -419,7 +419,7 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
xd->value_len = xsize; xd->value_len = xsize;
xd->data_crc = crc32(0, data, xd->name_len + 1 + xd->value_len); xd->data_crc = crc32(0, data, xd->name_len + 1 + xd->value_len);
rc = save_xattr_datum(c, xd, phys_ofs); rc = save_xattr_datum(c, xd);
if (rc) { if (rc) {
kfree(xd->xname); kfree(xd->xname);
jffs2_free_xattr_datum(xd); jffs2_free_xattr_datum(xd);
...@@ -446,9 +446,9 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c, ...@@ -446,9 +446,9 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c,
* delete_xattr_ref(c, ref) * delete_xattr_ref(c, ref)
* is used to delete jffs2_xattr_ref object. If the reference counter of xdatum * is used to delete jffs2_xattr_ref object. If the reference counter of xdatum
* is refered by this xref become 0, delete_xattr_datum() is called later. * is refered by this xref become 0, delete_xattr_datum() is called later.
* save_xattr_ref(c, ref, phys_ofs) * save_xattr_ref(c, ref)
* is used to write xref to medium. * is used to write xref to medium.
* create_xattr_ref(c, ic, xd, phys_ofs) * create_xattr_ref(c, ic, xd)
* is used to create a new xref and write to medium. * is used to create a new xref and write to medium.
* jffs2_xattr_delete_inode(c, ic) * jffs2_xattr_delete_inode(c, ic)
* is called to remove xrefs related to obsolete inode when inode is unlinked. * 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,19 +554,19 @@ static void delete_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *re
jffs2_free_xattr_ref(ref); jffs2_free_xattr_ref(ref);
} }
static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, uint32_t phys_ofs) static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
{ {
/* must be called under down_write(xattr_sem) */ /* must be called under down_write(xattr_sem) */
struct jffs2_raw_node_ref *raw; struct jffs2_raw_node_ref *raw;
struct jffs2_raw_xref rr; struct jffs2_raw_xref rr;
uint32_t length; uint32_t length;
uint32_t phys_ofs = write_ofs(c);
int ret; int ret;
raw = jffs2_alloc_raw_node_ref(); raw = jffs2_alloc_raw_node_ref();
if (!raw) if (!raw)
return -ENOMEM; return -ENOMEM;
raw->flash_offset = phys_ofs; raw->flash_offset = phys_ofs;
raw->next_in_ino = (void *)ref;
rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF); 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,8 +584,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
ret = ret ? ret : -EIO; ret = ret ? ret : -EIO;
if (length) { if (length) {
raw->flash_offset |= REF_OBSOLETE; raw->flash_offset |= REF_OBSOLETE;
raw->next_in_ino = NULL; jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)));
jffs2_mark_node_obsolete(c, raw); jffs2_mark_node_obsolete(c, raw);
} else { } else {
jffs2_free_raw_node_ref(raw); 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,7 +593,8 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
} }
raw->flash_offset |= REF_PRISTINE; raw->flash_offset |= REF_PRISTINE;
jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr))); jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
/* FIXME */ raw->next_in_ino = (void *)ref;
if (ref->node) if (ref->node)
delete_xattr_ref_node(c, ref); delete_xattr_ref_node(c, ref);
ref->node = raw; ref->node = raw;
...@@ -605,7 +605,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, ...@@ -605,7 +605,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
} }
static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic,
struct jffs2_xattr_datum *xd, uint32_t phys_ofs) struct jffs2_xattr_datum *xd)
{ {
/* must be called under down_write(xattr_sem) */ /* must be called under down_write(xattr_sem) */
struct jffs2_xattr_ref *ref; struct jffs2_xattr_ref *ref;
...@@ -617,7 +617,7 @@ static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct ...@@ -617,7 +617,7 @@ static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct
ref->ic = ic; ref->ic = ic;
ref->xd = xd; ref->xd = xd;
ret = save_xattr_ref(c, ref, phys_ofs); ret = save_xattr_ref(c, ref);
if (ret) { if (ret) {
jffs2_free_xattr_ref(ref); jffs2_free_xattr_ref(ref);
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -1063,7 +1063,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, ...@@ -1063,7 +1063,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
struct jffs2_inode_cache *ic = f->inocache; struct jffs2_inode_cache *ic = f->inocache;
struct jffs2_xattr_datum *xd; struct jffs2_xattr_datum *xd;
struct jffs2_xattr_ref *ref, *newref, **pref; struct jffs2_xattr_ref *ref, *newref, **pref;
uint32_t phys_ofs, length, request; uint32_t length, request;
int rc; int rc;
rc = check_xattr_ref_inode(c, ic); rc = check_xattr_ref_inode(c, ic);
...@@ -1071,7 +1071,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, ...@@ -1071,7 +1071,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
return rc; return rc;
request = PAD(sizeof(struct jffs2_raw_xattr) + strlen(xname) + 1 + size); request = PAD(sizeof(struct jffs2_raw_xattr) + strlen(xname) + 1 + size);
rc = jffs2_reserve_space(c, request, &phys_ofs, &length, rc = jffs2_reserve_space(c, request, &length,
ALLOC_NORMAL, JFFS2_SUMMARY_XATTR_SIZE); ALLOC_NORMAL, JFFS2_SUMMARY_XATTR_SIZE);
if (rc) { if (rc) {
JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request); 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,7 +1118,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
goto out; goto out;
} }
found: found:
xd = create_xattr_datum(c, xprefix, xname, buffer, size, phys_ofs); xd = create_xattr_datum(c, xprefix, xname, buffer, size);
if (IS_ERR(xd)) { if (IS_ERR(xd)) {
rc = PTR_ERR(xd); rc = PTR_ERR(xd);
goto out; goto out;
...@@ -1128,7 +1128,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, ...@@ -1128,7 +1128,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
/* create xattr_ref */ /* create xattr_ref */
request = PAD(sizeof(struct jffs2_raw_xref)); request = PAD(sizeof(struct jffs2_raw_xref));
rc = jffs2_reserve_space(c, request, &phys_ofs, &length, rc = jffs2_reserve_space(c, request, &length,
ALLOC_NORMAL, JFFS2_SUMMARY_XREF_SIZE); ALLOC_NORMAL, JFFS2_SUMMARY_XREF_SIZE);
if (rc) { if (rc) {
JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request); 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,7 +1142,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
down_write(&c->xattr_sem); down_write(&c->xattr_sem);
if (ref) if (ref)
*pref = ref->next; *pref = ref->next;
newref = create_xattr_ref(c, ic, xd, phys_ofs); newref = create_xattr_ref(c, ic, xd);
if (IS_ERR(newref)) { if (IS_ERR(newref)) {
if (ref) { if (ref) {
ref->next = ic->xref; ref->next = ic->xref;
...@@ -1171,7 +1171,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, ...@@ -1171,7 +1171,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
* -------------------------------------------------- */ * -------------------------------------------------- */
int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
{ {
uint32_t phys_ofs, totlen, length, old_ofs; uint32_t totlen, length, old_ofs;
int rc = -EINVAL; int rc = -EINVAL;
down_write(&c->xattr_sem); down_write(&c->xattr_sem);
...@@ -1191,13 +1191,13 @@ int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xatt ...@@ -1191,13 +1191,13 @@ int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xatt
} else if (unlikely(rc < 0)) } else if (unlikely(rc < 0))
goto out; goto out;
} }
rc = jffs2_reserve_space_gc(c, totlen, &phys_ofs, &length, JFFS2_SUMMARY_XATTR_SIZE); rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XATTR_SIZE);
if (rc || length < totlen) { if (rc || length < totlen) {
JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, totlen); JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, totlen);
rc = rc ? rc : -EBADFD; rc = rc ? rc : -EBADFD;
goto out; goto out;
} }
rc = save_xattr_datum(c, xd, phys_ofs); rc = save_xattr_datum(c, xd);
if (!rc) if (!rc)
dbg_xattr("xdatum (xid=%u, version=%u) GC'ed from %#08x to %08x\n", dbg_xattr("xdatum (xid=%u, version=%u) GC'ed from %#08x to %08x\n",
xd->xid, xd->version, old_ofs, ref_offset(xd->node)); 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,7 +1209,7 @@ int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xatt
int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
{ {
uint32_t phys_ofs, totlen, length, old_ofs; uint32_t totlen, length, old_ofs;
int rc = -EINVAL; int rc = -EINVAL;
down_write(&c->xattr_sem); down_write(&c->xattr_sem);
...@@ -1220,14 +1220,14 @@ int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ ...@@ -1220,14 +1220,14 @@ int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_
if (totlen != sizeof(struct jffs2_raw_xref)) if (totlen != sizeof(struct jffs2_raw_xref))
goto out; goto out;
rc = jffs2_reserve_space_gc(c, totlen, &phys_ofs, &length, JFFS2_SUMMARY_XREF_SIZE); rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XREF_SIZE);
if (rc || length < totlen) { if (rc || length < totlen) {
JFFS2_WARNING("%s: jffs2_reserve_space() = %d, request = %u\n", JFFS2_WARNING("%s: jffs2_reserve_space() = %d, request = %u\n",
__FUNCTION__, rc, totlen); __FUNCTION__, rc, totlen);
rc = rc ? rc : -EBADFD; rc = rc ? rc : -EBADFD;
goto out; goto out;
} }
rc = save_xattr_ref(c, ref, phys_ofs); rc = save_xattr_ref(c, ref);
if (!rc) if (!rc)
dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n", dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n",
ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node)); ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node));
......
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
struct jffs2_xattr_datum struct jffs2_xattr_datum
{ {
void *always_null; void *always_null;
u8 class;
u8 flags;
u16 xprefix; /* see JFFS2_XATTR_PREFIX_* */
struct jffs2_raw_node_ref *node; struct jffs2_raw_node_ref *node;
uint8_t class;
uint8_t flags;
uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */
struct list_head xindex; /* chained from c->xattrindex[n] */ struct list_head xindex; /* chained from c->xattrindex[n] */
uint32_t refcnt; /* # of xattr_ref refers this */ uint32_t refcnt; /* # of xattr_ref refers this */
uint32_t xid; uint32_t xid;
...@@ -42,11 +42,11 @@ struct jffs2_inode_cache; ...@@ -42,11 +42,11 @@ struct jffs2_inode_cache;
struct jffs2_xattr_ref struct jffs2_xattr_ref
{ {
void *always_null; void *always_null;
u8 class; struct jffs2_raw_node_ref *node;
u8 flags; /* Currently unused */ uint8_t class;
uint8_t flags; /* Currently unused */
u16 unused; u16 unused;
struct jffs2_raw_node_ref *node;
union { union {
struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */ struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
uint32_t ino; /* only used in scanning/building */ uint32_t ino; /* only used in scanning/building */
......
...@@ -66,8 +66,12 @@ struct mtd_info { ...@@ -66,8 +66,12 @@ struct mtd_info {
* information below if they desire * information below if they desire
*/ */
u_int32_t erasesize; u_int32_t erasesize;
/* Smallest availlable size for writing to the device. For NAND,
* this is the page size, for some NOR chips, the size of ECC
* covered blocks.
*/
u_int32_t writesize;
u_int32_t oobblock; // Size of OOB blocks (e.g. 512)
u_int32_t oobsize; // Amount of OOB data per block (e.g. 16) u_int32_t oobsize; // Amount of OOB data per block (e.g. 16)
u_int32_t ecctype; u_int32_t ecctype;
u_int32_t eccsize; u_int32_t eccsize;
...@@ -79,7 +83,6 @@ struct mtd_info { ...@@ -79,7 +83,6 @@ struct mtd_info {
* MTD_PROGRAM_REGIONS flag is set. * MTD_PROGRAM_REGIONS flag is set.
* (Maybe we should have an union for those?) * (Maybe we should have an union for those?)
*/ */
#define MTD_PROGREGION_SIZE(mtd) (mtd)->oobblock
#define MTD_PROGREGION_CTRLMODE_VALID(mtd) (mtd)->oobsize #define MTD_PROGREGION_CTRLMODE_VALID(mtd) (mtd)->oobsize
#define MTD_PROGREGION_CTRLMODE_INVALID(mtd) (mtd)->ecctype #define MTD_PROGREGION_CTRLMODE_INVALID(mtd) (mtd)->ecctype
......
...@@ -30,17 +30,14 @@ struct mtd_oob_buf { ...@@ -30,17 +30,14 @@ struct mtd_oob_buf {
#define MTD_NANDFLASH 4 #define MTD_NANDFLASH 4
#define MTD_DATAFLASH 6 #define MTD_DATAFLASH 6
#define MTD_CLEAR_BITS 1 // Bits can be cleared (flash) #define MTD_WRITEABLE 0x400 /* Device is writeable */
#define MTD_SET_BITS 2 // Bits can be set #define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */
#define MTD_ECC 128 // Device capable of automatic ECC
#define MTD_PROGRAM_REGIONS 512 // Configurable Programming Regions
// Some common devices / combinations of capabilities // Some common devices / combinations of capabilities
#define MTD_CAP_ROM 0 #define MTD_CAP_ROM 0
#define MTD_CAP_RAM (MTD_CLEAR_BITS|MTD_SET_BITS) #define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
#define MTD_CAP_NORFLASH (MTD_CLEAR_BITS) #define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
#define MTD_CAP_NANDFLASH (MTD_CLEAR_BITS) #define MTD_CAP_NANDFLASH (MTD_WRITEABLE)
#define MTD_WRITEABLE (MTD_CLEAR_BITS|MTD_SET_BITS)
// Types of automatic ECC/Checksum available // Types of automatic ECC/Checksum available
...@@ -65,7 +62,7 @@ struct mtd_info_user { ...@@ -65,7 +62,7 @@ struct mtd_info_user {
uint32_t flags; uint32_t flags;
uint32_t size; // Total size of the MTD uint32_t size; // Total size of the MTD
uint32_t erasesize; uint32_t erasesize;
uint32_t oobblock; // Size of OOB blocks (e.g. 512) uint32_t writesize;
uint32_t oobsize; // Amount of OOB data per block (e.g. 16) uint32_t oobsize; // Amount of OOB data per block (e.g. 16)
uint32_t ecctype; uint32_t ecctype;
uint32_t eccsize; uint32_t eccsize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment