aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/inftlcore.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-28 05:01:53 -0400
committerThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-29 09:06:50 -0400
commitf4a43cfcecfcaeeaa40a9dbc1d1378298c22446e (patch)
tree5647ebccb720c9d8ca314c8a3a5f6a660d000019 /drivers/mtd/inftlcore.c
parent5bd34c091a044d130601370c370f84b1c59f1627 (diff)
[MTD] Remove silly MTD_WRITE/READ macros
Most of those macros are unused and the used ones just obfuscate the code. Remove them and fixup all users. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/inftlcore.c')
-rw-r--r--drivers/mtd/inftlcore.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c
index ddd12993780d..3396f0e1ac5f 100644
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -197,10 +197,11 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
197 u16 BlockMap[MAX_SECTORS_PER_UNIT]; 197 u16 BlockMap[MAX_SECTORS_PER_UNIT];
198 unsigned char BlockDeleted[MAX_SECTORS_PER_UNIT]; 198 unsigned char BlockDeleted[MAX_SECTORS_PER_UNIT];
199 unsigned int thisEUN, prevEUN, status; 199 unsigned int thisEUN, prevEUN, status;
200 struct mtd_info *mtd = inftl->mbd.mtd;
200 int block, silly; 201 int block, silly;
201 unsigned int targetEUN; 202 unsigned int targetEUN;
202 struct inftl_oob oob; 203 struct inftl_oob oob;
203 size_t retlen; 204 size_t retlen;
204 205
205 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_foldchain(inftl=%p,thisVUC=%d," 206 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_foldchain(inftl=%p,thisVUC=%d,"
206 "pending=%d)\n", inftl, thisVUC, pendingblock); 207 "pending=%d)\n", inftl, thisVUC, pendingblock);
@@ -226,9 +227,9 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
226 if ((BlockMap[block] != 0xffff) || BlockDeleted[block]) 227 if ((BlockMap[block] != 0xffff) || BlockDeleted[block])
227 continue; 228 continue;
228 229
229 if (MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) 230 if (mtd->read_oob(mtd, (thisEUN * inftl->EraseSize)
230 + (block * SECTORSIZE), 16 , &retlen, 231 + (block * SECTORSIZE), 16 , &retlen,
231 (char *)&oob) < 0) 232 (char *)&oob) < 0)
232 status = SECTOR_IGNORE; 233 status = SECTOR_IGNORE;
233 else 234 else
234 status = oob.b.Status | oob.b.Status1; 235 status = oob.b.Status | oob.b.Status1;
@@ -288,13 +289,14 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
288 if (BlockMap[block] == BLOCK_NIL) 289 if (BlockMap[block] == BLOCK_NIL)
289 continue; 290 continue;
290 291
291 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * 292 ret = mtd->read(mtd, (inftl->EraseSize * BlockMap[block]) +
292 BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE, 293 (block * SECTORSIZE), SECTORSIZE, &retlen,
293 &retlen, movebuf); 294 movebuf);
294 if (ret < 0) { 295 if (ret < 0) {
295 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * 296 ret = mtd->read(mtd,
296 BlockMap[block]) + (block * SECTORSIZE), 297 (inftl->EraseSize * BlockMap[block]) +
297 SECTORSIZE, &retlen, movebuf); 298 (block * SECTORSIZE), SECTORSIZE,
299 &retlen, movebuf);
298 if (ret != -EIO) 300 if (ret != -EIO)
299 DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went " 301 DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went "
300 "away on retry?\n"); 302 "away on retry?\n");
@@ -415,6 +417,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
415 unsigned int thisVUC = block / (inftl->EraseSize / SECTORSIZE); 417 unsigned int thisVUC = block / (inftl->EraseSize / SECTORSIZE);
416 unsigned int thisEUN, writeEUN, prev_block, status; 418 unsigned int thisEUN, writeEUN, prev_block, status;
417 unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize -1); 419 unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize -1);
420 struct mtd_info *mtd = inftl->mbd.mtd;
418 struct inftl_oob oob; 421 struct inftl_oob oob;
419 struct inftl_bci bci; 422 struct inftl_bci bci;
420 unsigned char anac, nacs, parity; 423 unsigned char anac, nacs, parity;
@@ -434,8 +437,8 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
434 silly = MAX_LOOPS; 437 silly = MAX_LOOPS;
435 438
436 while (thisEUN <= inftl->lastEUN) { 439 while (thisEUN <= inftl->lastEUN) {
437 MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) + 440 mtd->read_oob(mtd, (thisEUN * inftl->EraseSize) +
438 blockofs, 8, &retlen, (char *)&bci); 441 blockofs, 8, &retlen, (char *)&bci);
439 442
440 status = bci.Status | bci.Status1; 443 status = bci.Status | bci.Status1;
441 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: status of block %d in " 444 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: status of block %d in "
@@ -522,8 +525,8 @@ hitused:
522 nacs = 0; 525 nacs = 0;
523 thisEUN = inftl->VUtable[thisVUC]; 526 thisEUN = inftl->VUtable[thisVUC];
524 if (thisEUN != BLOCK_NIL) { 527 if (thisEUN != BLOCK_NIL) {
525 MTD_READOOB(inftl->mbd.mtd, thisEUN * inftl->EraseSize 528 mtd->read_oob(mtd, thisEUN * inftl->EraseSize
526 + 8, 8, &retlen, (char *)&oob.u); 529 + 8, 8, &retlen, (char *)&oob.u);
527 anac = oob.u.a.ANAC + 1; 530 anac = oob.u.a.ANAC + 1;
528 nacs = oob.u.a.NACs + 1; 531 nacs = oob.u.a.NACs + 1;
529 } 532 }
@@ -544,8 +547,8 @@ hitused:
544 oob.u.a.parityPerField = parity; 547 oob.u.a.parityPerField = parity;
545 oob.u.a.discarded = 0xaa; 548 oob.u.a.discarded = 0xaa;
546 549
547 MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize + 8, 8, 550 mtd->write_oob(mtd, writeEUN * inftl->EraseSize + 8, 8,
548 &retlen, (char *)&oob.u); 551 &retlen, (char *)&oob.u);
549 552
550 /* Also back up header... */ 553 /* Also back up header... */
551 oob.u.b.virtualUnitNo = cpu_to_le16(thisVUC); 554 oob.u.b.virtualUnitNo = cpu_to_le16(thisVUC);
@@ -555,8 +558,8 @@ hitused:
555 oob.u.b.parityPerField = parity; 558 oob.u.b.parityPerField = parity;
556 oob.u.b.discarded = 0xaa; 559 oob.u.b.discarded = 0xaa;
557 560
558 MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize + 561 mtd->write_oob(mtd, writeEUN * inftl->EraseSize +
559 SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u); 562 SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u);
560 563
561 inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC]; 564 inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC];
562 inftl->VUtable[thisVUC] = writeEUN; 565 inftl->VUtable[thisVUC] = writeEUN;
@@ -576,6 +579,7 @@ hitused:
576 */ 579 */
577static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC) 580static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
578{ 581{
582 struct mtd_info *mtd = inftl->mbd.mtd;
579 unsigned char BlockUsed[MAX_SECTORS_PER_UNIT]; 583 unsigned char BlockUsed[MAX_SECTORS_PER_UNIT];
580 unsigned char BlockDeleted[MAX_SECTORS_PER_UNIT]; 584 unsigned char BlockDeleted[MAX_SECTORS_PER_UNIT];
581 unsigned int thisEUN, status; 585 unsigned int thisEUN, status;
@@ -606,9 +610,9 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
606 if (BlockUsed[block] || BlockDeleted[block]) 610 if (BlockUsed[block] || BlockDeleted[block])
607 continue; 611 continue;
608 612
609 if (MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) 613 if (mtd->read_oob(mtd, (thisEUN * inftl->EraseSize)
610 + (block * SECTORSIZE), 8 , &retlen, 614 + (block * SECTORSIZE), 8 , &retlen,
611 (char *)&bci) < 0) 615 (char *)&bci) < 0)
612 status = SECTOR_IGNORE; 616 status = SECTOR_IGNORE;
613 else 617 else
614 status = bci.Status | bci.Status1; 618 status = bci.Status | bci.Status1;
@@ -697,6 +701,7 @@ static int INFTL_deleteblock(struct INFTLrecord *inftl, unsigned block)
697{ 701{
698 unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)]; 702 unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)];
699 unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1); 703 unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1);
704 struct mtd_info *mtd = inftl->mbd.mtd;
700 unsigned int status; 705 unsigned int status;
701 int silly = MAX_LOOPS; 706 int silly = MAX_LOOPS;
702 size_t retlen; 707 size_t retlen;
@@ -706,8 +711,8 @@ static int INFTL_deleteblock(struct INFTLrecord *inftl, unsigned block)
706 "block=%d)\n", inftl, block); 711 "block=%d)\n", inftl, block);
707 712
708 while (thisEUN < inftl->nb_blocks) { 713 while (thisEUN < inftl->nb_blocks) {
709 if (MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) + 714 if (mtd->read_oob(mtd, (thisEUN * inftl->EraseSize) +
710 blockofs, 8, &retlen, (char *)&bci) < 0) 715 blockofs, 8, &retlen, (char *)&bci) < 0)
711 status = SECTOR_IGNORE; 716 status = SECTOR_IGNORE;
712 else 717 else
713 status = bci.Status | bci.Status1; 718 status = bci.Status | bci.Status1;
@@ -741,10 +746,10 @@ foundit:
741 if (thisEUN != BLOCK_NIL) { 746 if (thisEUN != BLOCK_NIL) {
742 loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs; 747 loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs;
743 748
744 if (MTD_READOOB(inftl->mbd.mtd, ptr, 8, &retlen, (char *)&bci) < 0) 749 if (mtd->read_oob(mtd, ptr, 8, &retlen, (char *)&bci) < 0)
745 return -EIO; 750 return -EIO;
746 bci.Status = bci.Status1 = SECTOR_DELETED; 751 bci.Status = bci.Status1 = SECTOR_DELETED;
747 if (MTD_WRITEOOB(inftl->mbd.mtd, ptr, 8, &retlen, (char *)&bci) < 0) 752 if (mtd->write_oob(mtd, ptr, 8, &retlen, (char *)&bci) < 0)
748 return -EIO; 753 return -EIO;
749 INFTL_trydeletechain(inftl, block / (inftl->EraseSize / SECTORSIZE)); 754 INFTL_trydeletechain(inftl, block / (inftl->EraseSize / SECTORSIZE));
750 } 755 }
@@ -805,6 +810,7 @@ static int inftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block,
805 struct INFTLrecord *inftl = (void *)mbd; 810 struct INFTLrecord *inftl = (void *)mbd;
806 unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)]; 811 unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)];
807 unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1); 812 unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1);
813 struct mtd_info *mtd = inftl->mbd.mtd;
808 unsigned int status; 814 unsigned int status;
809 int silly = MAX_LOOPS; 815 int silly = MAX_LOOPS;
810 struct inftl_bci bci; 816 struct inftl_bci bci;
@@ -814,8 +820,8 @@ static int inftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block,
814 "buffer=%p)\n", inftl, block, buffer); 820 "buffer=%p)\n", inftl, block, buffer);
815 821
816 while (thisEUN < inftl->nb_blocks) { 822 while (thisEUN < inftl->nb_blocks) {
817 if (MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) + 823 if (mtd->read_oob(mtd, (thisEUN * inftl->EraseSize) +
818 blockofs, 8, &retlen, (char *)&bci) < 0) 824 blockofs, 8, &retlen, (char *)&bci) < 0)
819 status = SECTOR_IGNORE; 825 status = SECTOR_IGNORE;
820 else 826 else
821 status = bci.Status | bci.Status1; 827 status = bci.Status | bci.Status1;
@@ -853,8 +859,7 @@ foundit:
853 } else { 859 } else {
854 size_t retlen; 860 size_t retlen;
855 loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs; 861 loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs;
856 if (MTD_READ(inftl->mbd.mtd, ptr, SECTORSIZE, &retlen, 862 if (mtd->read(mtd, ptr, SECTORSIZE, &retlen, buffer))
857 buffer))
858 return -EIO; 863 return -EIO;
859 } 864 }
860 return 0; 865 return 0;