提交 3975d167 编写于 作者: L Linus Torvalds

Merge git://git.infradead.org/~dwmw2/mtd-2.6.35

* git://git.infradead.org/~dwmw2/mtd-2.6.35:
  jffs2: update ctime when changing the file's permission by setfacl
  jffs2: Fix NFS race by using insert_inode_locked()
  jffs2: Fix in-core inode leaks on error paths
  mtd: Fix NAND submenu
  mtd/r852: update card detect early.
  mtd/r852: Fixes in case of DMA timeout
  mtd/r852: register IRQ as last step
  drivers/mtd: Use memdup_user
  docbook: make mtd nand module init static
...@@ -404,14 +404,9 @@ static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd, ...@@ -404,14 +404,9 @@ static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd,
if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
return -EINVAL; return -EINVAL;
ops.oobbuf = kmalloc(length, GFP_KERNEL); ops.oobbuf = memdup_user(ptr, length);
if (!ops.oobbuf) if (IS_ERR(ops.oobbuf))
return -ENOMEM; return PTR_ERR(ops.oobbuf);
if (copy_from_user(ops.oobbuf, ptr, length)) {
kfree(ops.oobbuf);
return -EFAULT;
}
start &= ~((uint64_t)mtd->oobsize - 1); start &= ~((uint64_t)mtd->oobsize - 1);
ret = mtd->write_oob(mtd, start, &ops); ret = mtd->write_oob(mtd, start, &ops);
......
menuconfig MTD_NAND
tristate "NAND Device Support"
depends on MTD
select MTD_NAND_IDS
select MTD_NAND_ECC
help
This enables support for accessing all type of NAND flash
devices. For further information see
<http://www.linux-mtd.infradead.org/doc/nand.html>.
config MTD_NAND_ECC config MTD_NAND_ECC
tristate tristate
...@@ -19,6 +9,17 @@ config MTD_NAND_ECC_SMC ...@@ -19,6 +9,17 @@ config MTD_NAND_ECC_SMC
Software ECC according to the Smart Media Specification. Software ECC according to the Smart Media Specification.
The original Linux implementation had byte 0 and 1 swapped. The original Linux implementation had byte 0 and 1 swapped.
menuconfig MTD_NAND
tristate "NAND Device Support"
depends on MTD
select MTD_NAND_IDS
select MTD_NAND_ECC
help
This enables support for accessing all type of NAND flash
devices. For further information see
<http://www.linux-mtd.infradead.org/doc/nand.html>.
if MTD_NAND if MTD_NAND
config MTD_NAND_VERIFY_WRITE config MTD_NAND_VERIFY_WRITE
......
...@@ -150,7 +150,6 @@ static void r852_dma_done(struct r852_device *dev, int error) ...@@ -150,7 +150,6 @@ static void r852_dma_done(struct r852_device *dev, int error)
if (dev->phys_dma_addr && dev->phys_dma_addr != dev->phys_bounce_buffer) if (dev->phys_dma_addr && dev->phys_dma_addr != dev->phys_bounce_buffer)
pci_unmap_single(dev->pci_dev, dev->phys_dma_addr, R852_DMA_LEN, pci_unmap_single(dev->pci_dev, dev->phys_dma_addr, R852_DMA_LEN,
dev->dma_dir ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); dev->dma_dir ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE);
complete(&dev->dma_done);
} }
/* /*
...@@ -182,6 +181,7 @@ static void r852_do_dma(struct r852_device *dev, uint8_t *buf, int do_read) ...@@ -182,6 +181,7 @@ static void r852_do_dma(struct r852_device *dev, uint8_t *buf, int do_read)
/* Set dma direction */ /* Set dma direction */
dev->dma_dir = do_read; dev->dma_dir = do_read;
dev->dma_stage = 1; dev->dma_stage = 1;
INIT_COMPLETION(dev->dma_done);
dbg_verbose("doing dma %s ", do_read ? "read" : "write"); dbg_verbose("doing dma %s ", do_read ? "read" : "write");
...@@ -494,6 +494,11 @@ int r852_ecc_correct(struct mtd_info *mtd, uint8_t *dat, ...@@ -494,6 +494,11 @@ int r852_ecc_correct(struct mtd_info *mtd, uint8_t *dat,
if (dev->card_unstable) if (dev->card_unstable)
return 0; return 0;
if (dev->dma_error) {
dev->dma_error = 0;
return -1;
}
r852_write_reg(dev, R852_CTL, dev->ctlreg | R852_CTL_ECC_ACCESS); r852_write_reg(dev, R852_CTL, dev->ctlreg | R852_CTL_ECC_ACCESS);
ecc_reg = r852_read_reg_dword(dev, R852_DATALINE); ecc_reg = r852_read_reg_dword(dev, R852_DATALINE);
r852_write_reg(dev, R852_CTL, dev->ctlreg); r852_write_reg(dev, R852_CTL, dev->ctlreg);
...@@ -707,6 +712,7 @@ void r852_card_detect_work(struct work_struct *work) ...@@ -707,6 +712,7 @@ void r852_card_detect_work(struct work_struct *work)
container_of(work, struct r852_device, card_detect_work.work); container_of(work, struct r852_device, card_detect_work.work);
r852_card_update_present(dev); r852_card_update_present(dev);
r852_update_card_detect(dev);
dev->card_unstable = 0; dev->card_unstable = 0;
/* False alarm */ /* False alarm */
...@@ -722,7 +728,6 @@ void r852_card_detect_work(struct work_struct *work) ...@@ -722,7 +728,6 @@ void r852_card_detect_work(struct work_struct *work)
else else
r852_unregister_nand_device(dev); r852_unregister_nand_device(dev);
exit: exit:
/* Update detection logic */
r852_update_card_detect(dev); r852_update_card_detect(dev);
} }
...@@ -796,6 +801,7 @@ static irqreturn_t r852_irq(int irq, void *data) ...@@ -796,6 +801,7 @@ static irqreturn_t r852_irq(int irq, void *data)
if (dma_status & R852_DMA_IRQ_ERROR) { if (dma_status & R852_DMA_IRQ_ERROR) {
dbg("recieved dma error IRQ"); dbg("recieved dma error IRQ");
r852_dma_done(dev, -EIO); r852_dma_done(dev, -EIO);
complete(&dev->dma_done);
goto out; goto out;
} }
...@@ -825,8 +831,10 @@ static irqreturn_t r852_irq(int irq, void *data) ...@@ -825,8 +831,10 @@ static irqreturn_t r852_irq(int irq, void *data)
r852_dma_enable(dev); r852_dma_enable(dev);
/* Operation done */ /* Operation done */
if (dev->dma_stage == 3) if (dev->dma_stage == 3) {
r852_dma_done(dev, 0); r852_dma_done(dev, 0);
complete(&dev->dma_done);
}
goto out; goto out;
} }
...@@ -940,18 +948,19 @@ int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) ...@@ -940,18 +948,19 @@ int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
r852_dma_test(dev); r852_dma_test(dev);
dev->irq = pci_dev->irq;
spin_lock_init(&dev->irqlock);
dev->card_detected = 0;
r852_card_update_present(dev);
/*register irq handler*/ /*register irq handler*/
error = -ENODEV; error = -ENODEV;
if (request_irq(pci_dev->irq, &r852_irq, IRQF_SHARED, if (request_irq(pci_dev->irq, &r852_irq, IRQF_SHARED,
DRV_NAME, dev)) DRV_NAME, dev))
goto error10; goto error10;
dev->irq = pci_dev->irq;
spin_lock_init(&dev->irqlock);
/* kick initial present test */ /* kick initial present test */
dev->card_detected = 0;
r852_card_update_present(dev);
queue_delayed_work(dev->card_workqueue, queue_delayed_work(dev->card_workqueue,
&dev->card_detect_work, 0); &dev->card_detect_work, 0);
...@@ -1081,7 +1090,7 @@ int r852_resume(struct device *device) ...@@ -1081,7 +1090,7 @@ int r852_resume(struct device *device)
dev->card_detected ? "added" : "removed"); dev->card_detected ? "added" : "removed");
queue_delayed_work(dev->card_workqueue, queue_delayed_work(dev->card_workqueue,
&dev->card_detect_work, 1000); &dev->card_detect_work, msecs_to_jiffies(1000));
return 0; return 0;
} }
......
...@@ -234,8 +234,9 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl) ...@@ -234,8 +234,9 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
if (inode->i_mode != mode) { if (inode->i_mode != mode) {
struct iattr attr; struct iattr attr;
attr.ia_valid = ATTR_MODE; attr.ia_valid = ATTR_MODE | ATTR_CTIME;
attr.ia_mode = mode; attr.ia_mode = mode;
attr.ia_ctime = CURRENT_TIME_SEC;
rc = jffs2_do_setattr(inode, &attr); rc = jffs2_do_setattr(inode, &attr);
if (rc < 0) if (rc < 0)
return rc; return rc;
......
...@@ -222,15 +222,18 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode, ...@@ -222,15 +222,18 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime)); dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime));
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
d_instantiate(dentry, inode);
D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n", D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n",
inode->i_ino, inode->i_mode, inode->i_nlink, inode->i_ino, inode->i_mode, inode->i_nlink,
f->inocache->pino_nlink, inode->i_mapping->nrpages)); f->inocache->pino_nlink, inode->i_mapping->nrpages));
d_instantiate(dentry, inode);
unlock_new_inode(inode);
return 0; return 0;
fail: fail:
make_bad_inode(inode); make_bad_inode(inode);
unlock_new_inode(inode);
iput(inode); iput(inode);
jffs2_free_raw_inode(ri); jffs2_free_raw_inode(ri);
return ret; return ret;
...@@ -360,8 +363,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -360,8 +363,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
/* Eeek. Wave bye bye */ /* Eeek. Wave bye bye */
mutex_unlock(&f->sem); mutex_unlock(&f->sem);
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_clear_inode(inode); ret = PTR_ERR(fn);
return PTR_ERR(fn); goto fail;
} }
/* We use f->target field to store the target path. */ /* We use f->target field to store the target path. */
...@@ -370,8 +373,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -370,8 +373,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
printk(KERN_WARNING "Can't allocate %d bytes of memory\n", targetlen + 1); printk(KERN_WARNING "Can't allocate %d bytes of memory\n", targetlen + 1);
mutex_unlock(&f->sem); mutex_unlock(&f->sem);
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_clear_inode(inode); ret = -ENOMEM;
return -ENOMEM; goto fail;
} }
memcpy(f->target, target, targetlen + 1); memcpy(f->target, target, targetlen + 1);
...@@ -386,30 +389,24 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -386,30 +389,24 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
ret = jffs2_init_security(inode, dir_i); ret = jffs2_init_security(inode, dir_i);
if (ret) { if (ret)
jffs2_clear_inode(inode); goto fail;
return ret;
}
ret = jffs2_init_acl_post(inode); ret = jffs2_init_acl_post(inode);
if (ret) { if (ret)
jffs2_clear_inode(inode); goto fail;
return ret;
}
ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &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. */ goto fail;
jffs2_clear_inode(inode);
return ret;
}
rd = jffs2_alloc_raw_dirent(); rd = jffs2_alloc_raw_dirent();
if (!rd) { if (!rd) {
/* Argh. Now we treat it like a normal delete */ /* Argh. Now we treat it like a normal delete */
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_clear_inode(inode); ret = -ENOMEM;
return -ENOMEM; goto fail;
} }
dir_f = JFFS2_INODE_INFO(dir_i); dir_f = JFFS2_INODE_INFO(dir_i);
...@@ -437,8 +434,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -437,8 +434,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_free_raw_dirent(rd); jffs2_free_raw_dirent(rd);
mutex_unlock(&dir_f->sem); mutex_unlock(&dir_f->sem);
jffs2_clear_inode(inode); ret = PTR_ERR(fd);
return PTR_ERR(fd); goto fail;
} }
dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime)); dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
...@@ -453,7 +450,14 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char ...@@ -453,7 +450,14 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
unlock_new_inode(inode);
return 0; return 0;
fail:
make_bad_inode(inode);
unlock_new_inode(inode);
iput(inode);
return ret;
} }
...@@ -519,8 +523,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) ...@@ -519,8 +523,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
/* Eeek. Wave bye bye */ /* Eeek. Wave bye bye */
mutex_unlock(&f->sem); mutex_unlock(&f->sem);
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_clear_inode(inode); ret = PTR_ERR(fn);
return PTR_ERR(fn); goto fail;
} }
/* No data here. Only a metadata node, which will be /* No data here. Only a metadata node, which will be
obsoleted by the first data write obsoleted by the first data write
...@@ -531,30 +535,24 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) ...@@ -531,30 +535,24 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
ret = jffs2_init_security(inode, dir_i); ret = jffs2_init_security(inode, dir_i);
if (ret) { if (ret)
jffs2_clear_inode(inode); goto fail;
return ret;
}
ret = jffs2_init_acl_post(inode); ret = jffs2_init_acl_post(inode);
if (ret) { if (ret)
jffs2_clear_inode(inode); goto fail;
return ret;
}
ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &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. */ goto fail;
jffs2_clear_inode(inode);
return ret;
}
rd = jffs2_alloc_raw_dirent(); rd = jffs2_alloc_raw_dirent();
if (!rd) { if (!rd) {
/* Argh. Now we treat it like a normal delete */ /* Argh. Now we treat it like a normal delete */
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_clear_inode(inode); ret = -ENOMEM;
return -ENOMEM; goto fail;
} }
dir_f = JFFS2_INODE_INFO(dir_i); dir_f = JFFS2_INODE_INFO(dir_i);
...@@ -582,8 +580,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) ...@@ -582,8 +580,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_free_raw_dirent(rd); jffs2_free_raw_dirent(rd);
mutex_unlock(&dir_f->sem); mutex_unlock(&dir_f->sem);
jffs2_clear_inode(inode); ret = PTR_ERR(fd);
return PTR_ERR(fd); goto fail;
} }
dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime)); dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
...@@ -599,7 +597,14 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) ...@@ -599,7 +597,14 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
unlock_new_inode(inode);
return 0; return 0;
fail:
make_bad_inode(inode);
unlock_new_inode(inode);
iput(inode);
return ret;
} }
static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry) static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
...@@ -693,8 +698,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de ...@@ -693,8 +698,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
/* Eeek. Wave bye bye */ /* Eeek. Wave bye bye */
mutex_unlock(&f->sem); mutex_unlock(&f->sem);
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_clear_inode(inode); ret = PTR_ERR(fn);
return PTR_ERR(fn); goto fail;
} }
/* No data here. Only a metadata node, which will be /* No data here. Only a metadata node, which will be
obsoleted by the first data write obsoleted by the first data write
...@@ -705,30 +710,24 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de ...@@ -705,30 +710,24 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
ret = jffs2_init_security(inode, dir_i); ret = jffs2_init_security(inode, dir_i);
if (ret) { if (ret)
jffs2_clear_inode(inode); goto fail;
return ret;
}
ret = jffs2_init_acl_post(inode); ret = jffs2_init_acl_post(inode);
if (ret) { if (ret)
jffs2_clear_inode(inode); goto fail;
return ret;
}
ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &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. */ goto fail;
jffs2_clear_inode(inode);
return ret;
}
rd = jffs2_alloc_raw_dirent(); rd = jffs2_alloc_raw_dirent();
if (!rd) { if (!rd) {
/* Argh. Now we treat it like a normal delete */ /* Argh. Now we treat it like a normal delete */
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_clear_inode(inode); ret = -ENOMEM;
return -ENOMEM; goto fail;
} }
dir_f = JFFS2_INODE_INFO(dir_i); dir_f = JFFS2_INODE_INFO(dir_i);
...@@ -759,8 +758,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de ...@@ -759,8 +758,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
jffs2_free_raw_dirent(rd); jffs2_free_raw_dirent(rd);
mutex_unlock(&dir_f->sem); mutex_unlock(&dir_f->sem);
jffs2_clear_inode(inode); ret = PTR_ERR(fd);
return PTR_ERR(fd); goto fail;
} }
dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime)); dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
...@@ -775,8 +774,14 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de ...@@ -775,8 +774,14 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
jffs2_complete_reservation(c); jffs2_complete_reservation(c);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
unlock_new_inode(inode);
return 0; return 0;
fail:
make_bad_inode(inode);
unlock_new_inode(inode);
iput(inode);
return ret;
} }
static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
......
...@@ -465,7 +465,12 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i ...@@ -465,7 +465,12 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i
inode->i_blocks = 0; inode->i_blocks = 0;
inode->i_size = 0; inode->i_size = 0;
insert_inode_hash(inode); if (insert_inode_locked(inode) < 0) {
make_bad_inode(inode);
unlock_new_inode(inode);
iput(inode);
return ERR_PTR(-EINVAL);
}
return inode; return inode;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册