aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/doc2001.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/devices/doc2001.c')
-rw-r--r--drivers/mtd/devices/doc2001.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
index 681a9c73a2a..0cf022a69e6 100644
--- a/drivers/mtd/devices/doc2001.c
+++ b/drivers/mtd/devices/doc2001.c
@@ -43,10 +43,10 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
43static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, 43static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
44 size_t *retlen, const u_char *buf, u_char *eccbuf, 44 size_t *retlen, const u_char *buf, u_char *eccbuf,
45 struct nand_oobinfo *oobsel); 45 struct nand_oobinfo *oobsel);
46static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 46static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
47 size_t *retlen, u_char *buf); 47 struct mtd_oob_ops *ops);
48static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 48static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
49 size_t *retlen, const u_char *buf); 49 struct mtd_oob_ops *ops);
50static int doc_erase (struct mtd_info *mtd, struct erase_info *instr); 50static int doc_erase (struct mtd_info *mtd, struct erase_info *instr);
51 51
52static struct mtd_info *docmillist = NULL; 52static struct mtd_info *docmillist = NULL;
@@ -324,16 +324,9 @@ static int DoCMil_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2)
324 return retval; 324 return retval;
325} 325}
326 326
327static const char im_name[] = "DoCMil_init"; 327/* This routine is found from the docprobe code by symbol_get(),
328 328 * which will bump the use count of this module. */
329/* This routine is made available to other mtd code via 329void DoCMil_init(struct mtd_info *mtd)
330 * inter_module_register. It must only be accessed through
331 * inter_module_get which will bump the use count of this module. The
332 * addresses passed back in mtd are valid as long as the use count of
333 * this module is non-zero, i.e. between inter_module_get and
334 * inter_module_put. Keith Owens <kaos@ocs.com.au> 29 Oct 2000.
335 */
336static void DoCMil_init(struct mtd_info *mtd)
337{ 330{
338 struct DiskOnChip *this = mtd->priv; 331 struct DiskOnChip *this = mtd->priv;
339 struct DiskOnChip *old = NULL; 332 struct DiskOnChip *old = NULL;
@@ -368,7 +361,7 @@ static void DoCMil_init(struct mtd_info *mtd)
368 /* FIXME: erase size is not always 8KiB */ 361 /* FIXME: erase size is not always 8KiB */
369 mtd->erasesize = 0x2000; 362 mtd->erasesize = 0x2000;
370 363
371 mtd->oobblock = 512; 364 mtd->writesize = 512;
372 mtd->oobsize = 16; 365 mtd->oobsize = 16;
373 mtd->owner = THIS_MODULE; 366 mtd->owner = THIS_MODULE;
374 mtd->erase = doc_erase; 367 mtd->erase = doc_erase;
@@ -376,8 +369,6 @@ static void DoCMil_init(struct mtd_info *mtd)
376 mtd->unpoint = NULL; 369 mtd->unpoint = NULL;
377 mtd->read = doc_read; 370 mtd->read = doc_read;
378 mtd->write = doc_write; 371 mtd->write = doc_write;
379 mtd->read_ecc = doc_read_ecc;
380 mtd->write_ecc = doc_write_ecc;
381 mtd->read_oob = doc_read_oob; 372 mtd->read_oob = doc_read_oob;
382 mtd->write_oob = doc_write_oob; 373 mtd->write_oob = doc_write_oob;
383 mtd->sync = NULL; 374 mtd->sync = NULL;
@@ -401,6 +392,7 @@ static void DoCMil_init(struct mtd_info *mtd)
401 return; 392 return;
402 } 393 }
403} 394}
395EXPORT_SYMBOL_GPL(DoCMil_init);
404 396
405static int doc_read (struct mtd_info *mtd, loff_t from, size_t len, 397static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
406 size_t *retlen, u_char *buf) 398 size_t *retlen, u_char *buf)
@@ -670,8 +662,8 @@ static int doc_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
670 return ret; 662 return ret;
671} 663}
672 664
673static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 665static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
674 size_t *retlen, u_char *buf) 666 struct mtd_oob_ops *ops)
675{ 667{
676#ifndef USE_MEMCPY 668#ifndef USE_MEMCPY
677 int i; 669 int i;
@@ -680,6 +672,12 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
680 struct DiskOnChip *this = mtd->priv; 672 struct DiskOnChip *this = mtd->priv;
681 void __iomem *docptr = this->virtadr; 673 void __iomem *docptr = this->virtadr;
682 struct Nand *mychip = &this->chips[ofs >> this->chipshift]; 674 struct Nand *mychip = &this->chips[ofs >> this->chipshift];
675 uint8_t *buf = ops->oobbuf;
676 size_t len = ops->len;
677
678 BUG_ON(ops->mode != MTD_OOB_PLACE);
679
680 ofs += ops->ooboffs;
683 681
684 /* Find the chip which is to be used and select it */ 682 /* Find the chip which is to be used and select it */
685 if (this->curfloor != mychip->floor) { 683 if (this->curfloor != mychip->floor) {
@@ -716,13 +714,13 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
716#endif 714#endif
717 buf[len - 1] = ReadDOC(docptr, LastDataRead); 715 buf[len - 1] = ReadDOC(docptr, LastDataRead);
718 716
719 *retlen = len; 717 ops->retlen = len;
720 718
721 return 0; 719 return 0;
722} 720}
723 721
724static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 722static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
725 size_t *retlen, const u_char *buf) 723 struct mtd_oob_ops *ops)
726{ 724{
727#ifndef USE_MEMCPY 725#ifndef USE_MEMCPY
728 int i; 726 int i;
@@ -732,6 +730,12 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
732 struct DiskOnChip *this = mtd->priv; 730 struct DiskOnChip *this = mtd->priv;
733 void __iomem *docptr = this->virtadr; 731 void __iomem *docptr = this->virtadr;
734 struct Nand *mychip = &this->chips[ofs >> this->chipshift]; 732 struct Nand *mychip = &this->chips[ofs >> this->chipshift];
733 uint8_t *buf = ops->oobbuf;
734 size_t len = ops->len;
735
736 BUG_ON(ops->mode != MTD_OOB_PLACE);
737
738 ofs += ops->ooboffs;
735 739
736 /* Find the chip which is to be used and select it */ 740 /* Find the chip which is to be used and select it */
737 if (this->curfloor != mychip->floor) { 741 if (this->curfloor != mychip->floor) {
@@ -783,12 +787,12 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
783 if (ReadDOC(docptr, Mil_CDSN_IO) & 1) { 787 if (ReadDOC(docptr, Mil_CDSN_IO) & 1) {
784 printk("Error programming oob data\n"); 788 printk("Error programming oob data\n");
785 /* FIXME: implement Bad Block Replacement (in nftl.c ??) */ 789 /* FIXME: implement Bad Block Replacement (in nftl.c ??) */
786 *retlen = 0; 790 ops->retlen = 0;
787 ret = -EIO; 791 ret = -EIO;
788 } 792 }
789 dummy = ReadDOC(docptr, LastDataRead); 793 dummy = ReadDOC(docptr, LastDataRead);
790 794
791 *retlen = len; 795 ops->retlen = len;
792 796
793 return ret; 797 return ret;
794} 798}
@@ -856,12 +860,6 @@ int doc_erase (struct mtd_info *mtd, struct erase_info *instr)
856 * 860 *
857 ****************************************************************************/ 861 ****************************************************************************/
858 862
859static int __init init_doc2001(void)
860{
861 inter_module_register(im_name, THIS_MODULE, &DoCMil_init);
862 return 0;
863}
864
865static void __exit cleanup_doc2001(void) 863static void __exit cleanup_doc2001(void)
866{ 864{
867 struct mtd_info *mtd; 865 struct mtd_info *mtd;
@@ -877,11 +875,9 @@ static void __exit cleanup_doc2001(void)
877 kfree(this->chips); 875 kfree(this->chips);
878 kfree(mtd); 876 kfree(mtd);
879 } 877 }
880 inter_module_unregister(im_name);
881} 878}
882 879
883module_exit(cleanup_doc2001); 880module_exit(cleanup_doc2001);
884module_init(init_doc2001);
885 881
886MODULE_LICENSE("GPL"); 882MODULE_LICENSE("GPL");
887MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org> et al."); 883MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org> et al.");