aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/doc2001plus.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/devices/doc2001plus.c')
-rw-r--r--drivers/mtd/devices/doc2001plus.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c
index 5f57f29efee4..66cb1e50469a 100644
--- a/drivers/mtd/devices/doc2001plus.c
+++ b/drivers/mtd/devices/doc2001plus.c
@@ -47,10 +47,10 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
47static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, 47static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
48 size_t *retlen, const u_char *buf, u_char *eccbuf, 48 size_t *retlen, const u_char *buf, u_char *eccbuf,
49 struct nand_oobinfo *oobsel); 49 struct nand_oobinfo *oobsel);
50static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 50static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
51 size_t *retlen, u_char *buf); 51 struct mtd_oob_ops *ops);
52static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 52static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
53 size_t *retlen, const u_char *buf); 53 struct mtd_oob_ops *ops);
54static int doc_erase (struct mtd_info *mtd, struct erase_info *instr); 54static int doc_erase (struct mtd_info *mtd, struct erase_info *instr);
55 55
56static struct mtd_info *docmilpluslist = NULL; 56static struct mtd_info *docmilpluslist = NULL;
@@ -447,16 +447,9 @@ static int DoCMilPlus_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2)
447 return retval; 447 return retval;
448} 448}
449 449
450static const char im_name[] = "DoCMilPlus_init"; 450/* This routine is found from the docprobe code by symbol_get(),
451 451 * which will bump the use count of this module. */
452/* This routine is made available to other mtd code via 452void DoCMilPlus_init(struct mtd_info *mtd)
453 * inter_module_register. It must only be accessed through
454 * inter_module_get which will bump the use count of this module. The
455 * addresses passed back in mtd are valid as long as the use count of
456 * this module is non-zero, i.e. between inter_module_get and
457 * inter_module_put. Keith Owens <kaos@ocs.com.au> 29 Oct 2000.
458 */
459static void DoCMilPlus_init(struct mtd_info *mtd)
460{ 453{
461 struct DiskOnChip *this = mtd->priv; 454 struct DiskOnChip *this = mtd->priv;
462 struct DiskOnChip *old = NULL; 455 struct DiskOnChip *old = NULL;
@@ -490,7 +483,7 @@ static void DoCMilPlus_init(struct mtd_info *mtd)
490 mtd->size = 0; 483 mtd->size = 0;
491 484
492 mtd->erasesize = 0; 485 mtd->erasesize = 0;
493 mtd->oobblock = 512; 486 mtd->writesize = 512;
494 mtd->oobsize = 16; 487 mtd->oobsize = 16;
495 mtd->owner = THIS_MODULE; 488 mtd->owner = THIS_MODULE;
496 mtd->erase = doc_erase; 489 mtd->erase = doc_erase;
@@ -498,8 +491,6 @@ static void DoCMilPlus_init(struct mtd_info *mtd)
498 mtd->unpoint = NULL; 491 mtd->unpoint = NULL;
499 mtd->read = doc_read; 492 mtd->read = doc_read;
500 mtd->write = doc_write; 493 mtd->write = doc_write;
501 mtd->read_ecc = doc_read_ecc;
502 mtd->write_ecc = doc_write_ecc;
503 mtd->read_oob = doc_read_oob; 494 mtd->read_oob = doc_read_oob;
504 mtd->write_oob = doc_write_oob; 495 mtd->write_oob = doc_write_oob;
505 mtd->sync = NULL; 496 mtd->sync = NULL;
@@ -524,6 +515,7 @@ static void DoCMilPlus_init(struct mtd_info *mtd)
524 return; 515 return;
525 } 516 }
526} 517}
518EXPORT_SYMBOL_GPL(DoCMilPlus_init);
527 519
528#if 0 520#if 0
529static int doc_dumpblk(struct mtd_info *mtd, loff_t from) 521static int doc_dumpblk(struct mtd_info *mtd, loff_t from)
@@ -876,14 +868,20 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
876 return ret; 868 return ret;
877} 869}
878 870
879static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 871static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
880 size_t *retlen, u_char *buf) 872 struct mtd_oob_ops *ops)
881{ 873{
882 loff_t fofs, base; 874 loff_t fofs, base;
883 struct DiskOnChip *this = mtd->priv; 875 struct DiskOnChip *this = mtd->priv;
884 void __iomem * docptr = this->virtadr; 876 void __iomem * docptr = this->virtadr;
885 struct Nand *mychip = &this->chips[ofs >> this->chipshift]; 877 struct Nand *mychip = &this->chips[ofs >> this->chipshift];
886 size_t i, size, got, want; 878 size_t i, size, got, want;
879 uint8_t *buf = ops->oobbuf;
880 size_t len = ops->len;
881
882 BUG_ON(ops->mode != MTD_OOB_PLACE);
883
884 ofs += ops->ooboffs;
887 885
888 DoC_CheckASIC(docptr); 886 DoC_CheckASIC(docptr);
889 887
@@ -949,12 +947,12 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
949 /* Disable flash internally */ 947 /* Disable flash internally */
950 WriteDOC(0, docptr, Mplus_FlashSelect); 948 WriteDOC(0, docptr, Mplus_FlashSelect);
951 949
952 *retlen = len; 950 ops->retlen = len;
953 return 0; 951 return 0;
954} 952}
955 953
956static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, 954static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
957 size_t *retlen, const u_char *buf) 955 struct mtd_oob_ops *ops)
958{ 956{
959 volatile char dummy; 957 volatile char dummy;
960 loff_t fofs, base; 958 loff_t fofs, base;
@@ -963,6 +961,12 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
963 struct Nand *mychip = &this->chips[ofs >> this->chipshift]; 961 struct Nand *mychip = &this->chips[ofs >> this->chipshift];
964 size_t i, size, got, want; 962 size_t i, size, got, want;
965 int ret = 0; 963 int ret = 0;
964 uint8_t *buf = ops->oobbuf;
965 size_t len = ops->len;
966
967 BUG_ON(ops->mode != MTD_OOB_PLACE);
968
969 ofs += ops->ooboffs;
966 970
967 DoC_CheckASIC(docptr); 971 DoC_CheckASIC(docptr);
968 972
@@ -1038,7 +1042,7 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
1038 printk("MTD: Error 0x%x programming oob at 0x%x\n", 1042 printk("MTD: Error 0x%x programming oob at 0x%x\n",
1039 dummy, (int)ofs); 1043 dummy, (int)ofs);
1040 /* FIXME: implement Bad Block Replacement */ 1044 /* FIXME: implement Bad Block Replacement */
1041 *retlen = 0; 1045 ops->retlen = 0;
1042 ret = -EIO; 1046 ret = -EIO;
1043 } 1047 }
1044 dummy = ReadDOC(docptr, Mplus_LastDataRead); 1048 dummy = ReadDOC(docptr, Mplus_LastDataRead);
@@ -1051,7 +1055,7 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
1051 /* Disable flash internally */ 1055 /* Disable flash internally */
1052 WriteDOC(0, docptr, Mplus_FlashSelect); 1056 WriteDOC(0, docptr, Mplus_FlashSelect);
1053 1057
1054 *retlen = len; 1058 ops->retlen = len;
1055 return ret; 1059 return ret;
1056} 1060}
1057 1061
@@ -1122,12 +1126,6 @@ int doc_erase(struct mtd_info *mtd, struct erase_info *instr)
1122 * 1126 *
1123 ****************************************************************************/ 1127 ****************************************************************************/
1124 1128
1125static int __init init_doc2001plus(void)
1126{
1127 inter_module_register(im_name, THIS_MODULE, &DoCMilPlus_init);
1128 return 0;
1129}
1130
1131static void __exit cleanup_doc2001plus(void) 1129static void __exit cleanup_doc2001plus(void)
1132{ 1130{
1133 struct mtd_info *mtd; 1131 struct mtd_info *mtd;
@@ -1143,11 +1141,9 @@ static void __exit cleanup_doc2001plus(void)
1143 kfree(this->chips); 1141 kfree(this->chips);
1144 kfree(mtd); 1142 kfree(mtd);
1145 } 1143 }
1146 inter_module_unregister(im_name);
1147} 1144}
1148 1145
1149module_exit(cleanup_doc2001plus); 1146module_exit(cleanup_doc2001plus);
1150module_init(init_doc2001plus);
1151 1147
1152MODULE_LICENSE("GPL"); 1148MODULE_LICENSE("GPL");
1153MODULE_AUTHOR("Greg Ungerer <gerg@snapgear.com> et al."); 1149MODULE_AUTHOR("Greg Ungerer <gerg@snapgear.com> et al.");