diff options
Diffstat (limited to 'drivers/mtd/devices/doc2001.c')
-rw-r--r-- | drivers/mtd/devices/doc2001.c | 60 |
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, | |||
43 | static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | 43 | static 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); |
46 | static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | 46 | static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, |
47 | size_t *retlen, u_char *buf); | 47 | struct mtd_oob_ops *ops); |
48 | static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | 48 | static 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); |
50 | static int doc_erase (struct mtd_info *mtd, struct erase_info *instr); | 50 | static int doc_erase (struct mtd_info *mtd, struct erase_info *instr); |
51 | 51 | ||
52 | static struct mtd_info *docmillist = NULL; | 52 | static 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 | ||
327 | static 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 | 329 | void 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 | */ | ||
336 | static 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 | } |
395 | EXPORT_SYMBOL_GPL(DoCMil_init); | ||
404 | 396 | ||
405 | static int doc_read (struct mtd_info *mtd, loff_t from, size_t len, | 397 | static 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 | ||
673 | static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | 665 | static 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 | ||
724 | static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | 722 | static 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 | ||
859 | static int __init init_doc2001(void) | ||
860 | { | ||
861 | inter_module_register(im_name, THIS_MODULE, &DoCMil_init); | ||
862 | return 0; | ||
863 | } | ||
864 | |||
865 | static void __exit cleanup_doc2001(void) | 863 | static 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 | ||
883 | module_exit(cleanup_doc2001); | 880 | module_exit(cleanup_doc2001); |
884 | module_init(init_doc2001); | ||
885 | 881 | ||
886 | MODULE_LICENSE("GPL"); | 882 | MODULE_LICENSE("GPL"); |
887 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org> et al."); | 883 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org> et al."); |