diff options
author | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 11:21:03 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 11:21:03 -0400 |
commit | 9223a456da8ed357bf7e0b128c853e2c8bd54614 (patch) | |
tree | 50cb225c4ba9c610ae4cb67231b319e78e935ac4 /drivers/mtd/inftlcore.c | |
parent | 2528e8cdf376d7da24647c442ec1e88c360d76ca (diff) |
[MTD] Remove read/write _ecc variants
MTD clients are agnostic of FLASH which needs ECC suppport.
Remove the functions and fixup the callers.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/inftlcore.c')
-rw-r--r-- | drivers/mtd/inftlcore.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c index a3b92479719d..ddd12993780d 100644 --- a/drivers/mtd/inftlcore.c +++ b/drivers/mtd/inftlcore.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/mtd/mtd.h> | 36 | #include <linux/mtd/mtd.h> |
37 | #include <linux/mtd/nftl.h> | 37 | #include <linux/mtd/nftl.h> |
38 | #include <linux/mtd/inftl.h> | 38 | #include <linux/mtd/inftl.h> |
39 | #include <linux/mtd/nand.h> | ||
39 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
40 | #include <asm/errno.h> | 41 | #include <asm/errno.h> |
41 | #include <asm/io.h> | 42 | #include <asm/io.h> |
@@ -79,14 +80,12 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
79 | inftl->mbd.devnum = -1; | 80 | inftl->mbd.devnum = -1; |
80 | inftl->mbd.blksize = 512; | 81 | inftl->mbd.blksize = 512; |
81 | inftl->mbd.tr = tr; | 82 | inftl->mbd.tr = tr; |
82 | memcpy(&inftl->oobinfo, &mtd->oobinfo, sizeof(struct nand_oobinfo)); | ||
83 | inftl->oobinfo.useecc = MTD_NANDECC_PLACEONLY; | ||
84 | 83 | ||
85 | if (INFTL_mount(inftl) < 0) { | 84 | if (INFTL_mount(inftl) < 0) { |
86 | printk(KERN_WARNING "INFTL: could not mount device\n"); | 85 | printk(KERN_WARNING "INFTL: could not mount device\n"); |
87 | kfree(inftl); | 86 | kfree(inftl); |
88 | return; | 87 | return; |
89 | } | 88 | } |
90 | 89 | ||
91 | /* OK, it's a new one. Set up all the data structures. */ | 90 | /* OK, it's a new one. Set up all the data structures. */ |
92 | 91 | ||
@@ -221,7 +220,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned | |||
221 | * Scan to find the Erase Unit which holds the actual data for each | 220 | * Scan to find the Erase Unit which holds the actual data for each |
222 | * 512-byte block within the Chain. | 221 | * 512-byte block within the Chain. |
223 | */ | 222 | */ |
224 | silly = MAX_LOOPS; | 223 | silly = MAX_LOOPS; |
225 | while (thisEUN < inftl->nb_blocks) { | 224 | while (thisEUN < inftl->nb_blocks) { |
226 | for (block = 0; block < inftl->EraseSize/SECTORSIZE; block ++) { | 225 | for (block = 0; block < inftl->EraseSize/SECTORSIZE; block ++) { |
227 | if ((BlockMap[block] != 0xffff) || BlockDeleted[block]) | 226 | if ((BlockMap[block] != 0xffff) || BlockDeleted[block]) |
@@ -232,7 +231,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned | |||
232 | (char *)&oob) < 0) | 231 | (char *)&oob) < 0) |
233 | status = SECTOR_IGNORE; | 232 | status = SECTOR_IGNORE; |
234 | else | 233 | else |
235 | status = oob.b.Status | oob.b.Status1; | 234 | status = oob.b.Status | oob.b.Status1; |
236 | 235 | ||
237 | switch(status) { | 236 | switch(status) { |
238 | case SECTOR_FREE: | 237 | case SECTOR_FREE: |
@@ -282,29 +281,30 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned | |||
282 | continue; | 281 | continue; |
283 | } | 282 | } |
284 | 283 | ||
285 | /* | 284 | /* |
286 | * Copy only in non free block (free blocks can only | 285 | * Copy only in non free block (free blocks can only |
287 | * happen in case of media errors or deleted blocks). | 286 | * happen in case of media errors or deleted blocks). |
288 | */ | 287 | */ |
289 | if (BlockMap[block] == BLOCK_NIL) | 288 | if (BlockMap[block] == BLOCK_NIL) |
290 | continue; | 289 | continue; |
291 | 290 | ||
292 | ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * | 291 | ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * |
293 | BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE, | 292 | BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE, |
294 | &retlen, movebuf); | 293 | &retlen, movebuf); |
295 | if (ret < 0) { | 294 | if (ret < 0) { |
296 | ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * | 295 | ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * |
297 | BlockMap[block]) + (block * SECTORSIZE), | 296 | BlockMap[block]) + (block * SECTORSIZE), |
298 | SECTORSIZE, &retlen, movebuf); | 297 | SECTORSIZE, &retlen, movebuf); |
299 | if (ret != -EIO) | 298 | if (ret != -EIO) |
300 | DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went " | 299 | DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went " |
301 | "away on retry?\n"); | 300 | "away on retry?\n"); |
302 | } | 301 | } |
303 | memset(&oob, 0xff, sizeof(struct inftl_oob)); | 302 | memset(&oob, 0xff, sizeof(struct inftl_oob)); |
304 | oob.b.Status = oob.b.Status1 = SECTOR_USED; | 303 | oob.b.Status = oob.b.Status1 = SECTOR_USED; |
305 | MTD_WRITEECC(inftl->mbd.mtd, (inftl->EraseSize * targetEUN) + | 304 | |
306 | (block * SECTORSIZE), SECTORSIZE, &retlen, | 305 | nand_write_raw(inftl->mbd.mtd, (inftl->EraseSize * targetEUN) + |
307 | movebuf, (char *)&oob, &inftl->oobinfo); | 306 | (block * SECTORSIZE), SECTORSIZE, &retlen, |
307 | movebuf, (char *)&oob); | ||
308 | } | 308 | } |
309 | 309 | ||
310 | /* | 310 | /* |
@@ -329,17 +329,17 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned | |||
329 | if (thisEUN == targetEUN) | 329 | if (thisEUN == targetEUN) |
330 | break; | 330 | break; |
331 | 331 | ||
332 | if (INFTL_formatblock(inftl, thisEUN) < 0) { | 332 | if (INFTL_formatblock(inftl, thisEUN) < 0) { |
333 | /* | 333 | /* |
334 | * Could not erase : mark block as reserved. | 334 | * Could not erase : mark block as reserved. |
335 | */ | 335 | */ |
336 | inftl->PUtable[thisEUN] = BLOCK_RESERVED; | 336 | inftl->PUtable[thisEUN] = BLOCK_RESERVED; |
337 | } else { | 337 | } else { |
338 | /* Correctly erased : mark it as free */ | 338 | /* Correctly erased : mark it as free */ |
339 | inftl->PUtable[thisEUN] = BLOCK_FREE; | 339 | inftl->PUtable[thisEUN] = BLOCK_FREE; |
340 | inftl->PUtable[prevEUN] = BLOCK_NIL; | 340 | inftl->PUtable[prevEUN] = BLOCK_NIL; |
341 | inftl->numfreeEUNs++; | 341 | inftl->numfreeEUNs++; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | return targetEUN; | 345 | return targetEUN; |
@@ -437,7 +437,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) | |||
437 | MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) + | 437 | MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) + |
438 | blockofs, 8, &retlen, (char *)&bci); | 438 | blockofs, 8, &retlen, (char *)&bci); |
439 | 439 | ||
440 | status = bci.Status | bci.Status1; | 440 | status = bci.Status | bci.Status1; |
441 | DEBUG(MTD_DEBUG_LEVEL3, "INFTL: status of block %d in " | 441 | DEBUG(MTD_DEBUG_LEVEL3, "INFTL: status of block %d in " |
442 | "EUN %d is %x\n", block , writeEUN, status); | 442 | "EUN %d is %x\n", block , writeEUN, status); |
443 | 443 | ||
@@ -670,12 +670,12 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC) | |||
670 | DEBUG(MTD_DEBUG_LEVEL3, "Deleting EUN %d from VUC %d\n", | 670 | DEBUG(MTD_DEBUG_LEVEL3, "Deleting EUN %d from VUC %d\n", |
671 | thisEUN, thisVUC); | 671 | thisEUN, thisVUC); |
672 | 672 | ||
673 | if (INFTL_formatblock(inftl, thisEUN) < 0) { | 673 | if (INFTL_formatblock(inftl, thisEUN) < 0) { |
674 | /* | 674 | /* |
675 | * Could not erase : mark block as reserved. | 675 | * Could not erase : mark block as reserved. |
676 | */ | 676 | */ |
677 | inftl->PUtable[thisEUN] = BLOCK_RESERVED; | 677 | inftl->PUtable[thisEUN] = BLOCK_RESERVED; |
678 | } else { | 678 | } else { |
679 | /* Correctly erased : mark it as free */ | 679 | /* Correctly erased : mark it as free */ |
680 | inftl->PUtable[thisEUN] = BLOCK_FREE; | 680 | inftl->PUtable[thisEUN] = BLOCK_FREE; |
681 | inftl->numfreeEUNs++; | 681 | inftl->numfreeEUNs++; |
@@ -784,9 +784,10 @@ static int inftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block, | |||
784 | 784 | ||
785 | memset(&oob, 0xff, sizeof(struct inftl_oob)); | 785 | memset(&oob, 0xff, sizeof(struct inftl_oob)); |
786 | oob.b.Status = oob.b.Status1 = SECTOR_USED; | 786 | oob.b.Status = oob.b.Status1 = SECTOR_USED; |
787 | MTD_WRITEECC(inftl->mbd.mtd, (writeEUN * inftl->EraseSize) + | 787 | |
788 | blockofs, SECTORSIZE, &retlen, (char *)buffer, | 788 | nand_write_raw(inftl->mbd.mtd, (writeEUN * inftl->EraseSize) + |
789 | (char *)&oob, &inftl->oobinfo); | 789 | blockofs, SECTORSIZE, &retlen, (char *)buffer, |
790 | (char *)&oob); | ||
790 | /* | 791 | /* |
791 | * need to write SECTOR_USED flags since they are not written | 792 | * need to write SECTOR_USED flags since they are not written |
792 | * in mtd_writeecc | 793 | * in mtd_writeecc |
@@ -804,9 +805,9 @@ static int inftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block, | |||
804 | struct INFTLrecord *inftl = (void *)mbd; | 805 | struct INFTLrecord *inftl = (void *)mbd; |
805 | unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)]; | 806 | unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)]; |
806 | unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1); | 807 | unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1); |
807 | unsigned int status; | 808 | unsigned int status; |
808 | int silly = MAX_LOOPS; | 809 | int silly = MAX_LOOPS; |
809 | struct inftl_bci bci; | 810 | struct inftl_bci bci; |
810 | size_t retlen; | 811 | size_t retlen; |
811 | 812 | ||
812 | DEBUG(MTD_DEBUG_LEVEL3, "INFTL: inftl_readblock(inftl=%p,block=%ld," | 813 | DEBUG(MTD_DEBUG_LEVEL3, "INFTL: inftl_readblock(inftl=%p,block=%ld," |
@@ -850,7 +851,7 @@ foundit: | |||
850 | /* The requested block is not on the media, return all 0x00 */ | 851 | /* The requested block is not on the media, return all 0x00 */ |
851 | memset(buffer, 0, SECTORSIZE); | 852 | memset(buffer, 0, SECTORSIZE); |
852 | } else { | 853 | } else { |
853 | size_t retlen; | 854 | size_t retlen; |
854 | loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs; | 855 | loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs; |
855 | if (MTD_READ(inftl->mbd.mtd, ptr, SECTORSIZE, &retlen, | 856 | if (MTD_READ(inftl->mbd.mtd, ptr, SECTORSIZE, &retlen, |
856 | buffer)) | 857 | buffer)) |