aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/mtdchar.c11
-rw-r--r--drivers/mtd/nand/Kconfig21
-rw-r--r--drivers/mtd/nand/r852.c27
3 files changed, 32 insertions, 27 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 000d65ea55a4..91c8013cf0d9 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -404,14 +404,9 @@ static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd,
404 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) 404 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
405 return -EINVAL; 405 return -EINVAL;
406 406
407 ops.oobbuf = kmalloc(length, GFP_KERNEL); 407 ops.oobbuf = memdup_user(ptr, length);
408 if (!ops.oobbuf) 408 if (IS_ERR(ops.oobbuf))
409 return -ENOMEM; 409 return PTR_ERR(ops.oobbuf);
410
411 if (copy_from_user(ops.oobbuf, ptr, length)) {
412 kfree(ops.oobbuf);
413 return -EFAULT;
414 }
415 410
416 start &= ~((uint64_t)mtd->oobsize - 1); 411 start &= ~((uint64_t)mtd->oobsize - 1);
417 ret = mtd->write_oob(mtd, start, &ops); 412 ret = mtd->write_oob(mtd, start, &ops);
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 98a04b3c9526..ffc3720929f1 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -1,13 +1,3 @@
1menuconfig MTD_NAND
2 tristate "NAND Device Support"
3 depends on MTD
4 select MTD_NAND_IDS
5 select MTD_NAND_ECC
6 help
7 This enables support for accessing all type of NAND flash
8 devices. For further information see
9 <http://www.linux-mtd.infradead.org/doc/nand.html>.
10
11config MTD_NAND_ECC 1config MTD_NAND_ECC
12 tristate 2 tristate
13 3
@@ -19,6 +9,17 @@ config MTD_NAND_ECC_SMC
19 Software ECC according to the Smart Media Specification. 9 Software ECC according to the Smart Media Specification.
20 The original Linux implementation had byte 0 and 1 swapped. 10 The original Linux implementation had byte 0 and 1 swapped.
21 11
12
13menuconfig MTD_NAND
14 tristate "NAND Device Support"
15 depends on MTD
16 select MTD_NAND_IDS
17 select MTD_NAND_ECC
18 help
19 This enables support for accessing all type of NAND flash
20 devices. For further information see
21 <http://www.linux-mtd.infradead.org/doc/nand.html>.
22
22if MTD_NAND 23if MTD_NAND
23 24
24config MTD_NAND_VERIFY_WRITE 25config MTD_NAND_VERIFY_WRITE
diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
index 78a423295474..bcfc851fe550 100644
--- a/drivers/mtd/nand/r852.c
+++ b/drivers/mtd/nand/r852.c
@@ -150,7 +150,6 @@ static void r852_dma_done(struct r852_device *dev, int error)
150 if (dev->phys_dma_addr && dev->phys_dma_addr != dev->phys_bounce_buffer) 150 if (dev->phys_dma_addr && dev->phys_dma_addr != dev->phys_bounce_buffer)
151 pci_unmap_single(dev->pci_dev, dev->phys_dma_addr, R852_DMA_LEN, 151 pci_unmap_single(dev->pci_dev, dev->phys_dma_addr, R852_DMA_LEN,
152 dev->dma_dir ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); 152 dev->dma_dir ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE);
153 complete(&dev->dma_done);
154} 153}
155 154
156/* 155/*
@@ -182,6 +181,7 @@ static void r852_do_dma(struct r852_device *dev, uint8_t *buf, int do_read)
182 /* Set dma direction */ 181 /* Set dma direction */
183 dev->dma_dir = do_read; 182 dev->dma_dir = do_read;
184 dev->dma_stage = 1; 183 dev->dma_stage = 1;
184 INIT_COMPLETION(dev->dma_done);
185 185
186 dbg_verbose("doing dma %s ", do_read ? "read" : "write"); 186 dbg_verbose("doing dma %s ", do_read ? "read" : "write");
187 187
@@ -494,6 +494,11 @@ int r852_ecc_correct(struct mtd_info *mtd, uint8_t *dat,
494 if (dev->card_unstable) 494 if (dev->card_unstable)
495 return 0; 495 return 0;
496 496
497 if (dev->dma_error) {
498 dev->dma_error = 0;
499 return -1;
500 }
501
497 r852_write_reg(dev, R852_CTL, dev->ctlreg | R852_CTL_ECC_ACCESS); 502 r852_write_reg(dev, R852_CTL, dev->ctlreg | R852_CTL_ECC_ACCESS);
498 ecc_reg = r852_read_reg_dword(dev, R852_DATALINE); 503 ecc_reg = r852_read_reg_dword(dev, R852_DATALINE);
499 r852_write_reg(dev, R852_CTL, dev->ctlreg); 504 r852_write_reg(dev, R852_CTL, dev->ctlreg);
@@ -707,6 +712,7 @@ void r852_card_detect_work(struct work_struct *work)
707 container_of(work, struct r852_device, card_detect_work.work); 712 container_of(work, struct r852_device, card_detect_work.work);
708 713
709 r852_card_update_present(dev); 714 r852_card_update_present(dev);
715 r852_update_card_detect(dev);
710 dev->card_unstable = 0; 716 dev->card_unstable = 0;
711 717
712 /* False alarm */ 718 /* False alarm */
@@ -722,7 +728,6 @@ void r852_card_detect_work(struct work_struct *work)
722 else 728 else
723 r852_unregister_nand_device(dev); 729 r852_unregister_nand_device(dev);
724exit: 730exit:
725 /* Update detection logic */
726 r852_update_card_detect(dev); 731 r852_update_card_detect(dev);
727} 732}
728 733
@@ -796,6 +801,7 @@ static irqreturn_t r852_irq(int irq, void *data)
796 if (dma_status & R852_DMA_IRQ_ERROR) { 801 if (dma_status & R852_DMA_IRQ_ERROR) {
797 dbg("recieved dma error IRQ"); 802 dbg("recieved dma error IRQ");
798 r852_dma_done(dev, -EIO); 803 r852_dma_done(dev, -EIO);
804 complete(&dev->dma_done);
799 goto out; 805 goto out;
800 } 806 }
801 807
@@ -825,8 +831,10 @@ static irqreturn_t r852_irq(int irq, void *data)
825 r852_dma_enable(dev); 831 r852_dma_enable(dev);
826 832
827 /* Operation done */ 833 /* Operation done */
828 if (dev->dma_stage == 3) 834 if (dev->dma_stage == 3) {
829 r852_dma_done(dev, 0); 835 r852_dma_done(dev, 0);
836 complete(&dev->dma_done);
837 }
830 goto out; 838 goto out;
831 } 839 }
832 840
@@ -940,18 +948,19 @@ int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
940 948
941 r852_dma_test(dev); 949 r852_dma_test(dev);
942 950
951 dev->irq = pci_dev->irq;
952 spin_lock_init(&dev->irqlock);
953
954 dev->card_detected = 0;
955 r852_card_update_present(dev);
956
943 /*register irq handler*/ 957 /*register irq handler*/
944 error = -ENODEV; 958 error = -ENODEV;
945 if (request_irq(pci_dev->irq, &r852_irq, IRQF_SHARED, 959 if (request_irq(pci_dev->irq, &r852_irq, IRQF_SHARED,
946 DRV_NAME, dev)) 960 DRV_NAME, dev))
947 goto error10; 961 goto error10;
948 962
949 dev->irq = pci_dev->irq;
950 spin_lock_init(&dev->irqlock);
951
952 /* kick initial present test */ 963 /* kick initial present test */
953 dev->card_detected = 0;
954 r852_card_update_present(dev);
955 queue_delayed_work(dev->card_workqueue, 964 queue_delayed_work(dev->card_workqueue,
956 &dev->card_detect_work, 0); 965 &dev->card_detect_work, 0);
957 966
@@ -1081,7 +1090,7 @@ int r852_resume(struct device *device)
1081 dev->card_detected ? "added" : "removed"); 1090 dev->card_detected ? "added" : "removed");
1082 1091
1083 queue_delayed_work(dev->card_workqueue, 1092 queue_delayed_work(dev->card_workqueue,
1084 &dev->card_detect_work, 1000); 1093 &dev->card_detect_work, msecs_to_jiffies(1000));
1085 return 0; 1094 return 0;
1086 } 1095 }
1087 1096