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.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
index 579c0b570ae5..0cf022a69e65 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;
@@ -662,8 +662,8 @@ static int doc_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
662 return ret; 662 return ret;
663} 663}
664 664
665static 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,
666 size_t *retlen, u_char *buf) 666 struct mtd_oob_ops *ops)
667{ 667{
668#ifndef USE_MEMCPY 668#ifndef USE_MEMCPY
669 int i; 669 int i;
@@ -672,6 +672,12 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
672 struct DiskOnChip *this = mtd->priv; 672 struct DiskOnChip *this = mtd->priv;
673 void __iomem *docptr = this->virtadr; 673 void __iomem *docptr = this->virtadr;
674 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;
675 681
676 /* Find the chip which is to be used and select it */ 682 /* Find the chip which is to be used and select it */
677 if (this->curfloor != mychip->floor) { 683 if (this->curfloor != mychip->floor) {
@@ -708,13 +714,13 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
708#endif 714#endif
709 buf[len - 1] = ReadDOC(docptr, LastDataRead); 715 buf[len - 1] = ReadDOC(docptr, LastDataRead);
710 716
711 *retlen = len; 717 ops->retlen = len;
712 718
713 return 0; 719 return 0;
714} 720}
715 721
716static 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,
717 size_t *retlen, const u_char *buf) 723 struct mtd_oob_ops *ops)
718{ 724{
719#ifndef USE_MEMCPY 725#ifndef USE_MEMCPY
720 int i; 726 int i;
@@ -724,6 +730,12 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
724 struct DiskOnChip *this = mtd->priv; 730 struct DiskOnChip *this = mtd->priv;
725 void __iomem *docptr = this->virtadr; 731 void __iomem *docptr = this->virtadr;
726 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;
727 739
728 /* Find the chip which is to be used and select it */ 740 /* Find the chip which is to be used and select it */
729 if (this->curfloor != mychip->floor) { 741 if (this->curfloor != mychip->floor) {
@@ -775,12 +787,12 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
775 if (ReadDOC(docptr, Mil_CDSN_IO) & 1) { 787 if (ReadDOC(docptr, Mil_CDSN_IO) & 1) {
776 printk("Error programming oob data\n"); 788 printk("Error programming oob data\n");
777 /* FIXME: implement Bad Block Replacement (in nftl.c ??) */ 789 /* FIXME: implement Bad Block Replacement (in nftl.c ??) */
778 *retlen = 0; 790 ops->retlen = 0;
779 ret = -EIO; 791 ret = -EIO;
780 } 792 }
781 dummy = ReadDOC(docptr, LastDataRead); 793 dummy = ReadDOC(docptr, LastDataRead);
782 794
783 *retlen = len; 795 ops->retlen = len;
784 796
785 return ret; 797 return ret;
786} 798}