aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nftlmount.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nftlmount.c')
-rw-r--r--drivers/mtd/nftlmount.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
index 521b07cd2326..067262ee8df0 100644
--- a/drivers/mtd/nftlmount.c
+++ b/drivers/mtd/nftlmount.c
@@ -33,6 +33,11 @@
33 33
34char nftlmountrev[]="$Revision: 1.41 $"; 34char nftlmountrev[]="$Revision: 1.41 $";
35 35
36extern int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
37 size_t *retlen, uint8_t *buf);
38extern int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
39 size_t *retlen, uint8_t *buf);
40
36/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the 41/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the
37 * various device information of the NFTL partition and Bad Unit Table. Update 42 * various device information of the NFTL partition and Bad Unit Table. Update
38 * the ReplUnitTable[] table accroding to the Bad Unit Table. ReplUnitTable[] 43 * the ReplUnitTable[] table accroding to the Bad Unit Table. ReplUnitTable[]
@@ -92,7 +97,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
92 } 97 }
93 98
94 /* To be safer with BIOS, also use erase mark as discriminant */ 99 /* To be safer with BIOS, also use erase mark as discriminant */
95 if ((ret = mtd->read_oob(mtd, block * nftl->EraseSize + 100 if ((ret = nftl_read_oob(mtd, block * nftl->EraseSize +
96 SECTORSIZE + 8, 8, &retlen, 101 SECTORSIZE + 8, 8, &retlen,
97 (char *)&h1) < 0)) { 102 (char *)&h1) < 0)) {
98 printk(KERN_WARNING "ANAND header found at 0x%x in mtd%d, but OOB data read failed (err %d)\n", 103 printk(KERN_WARNING "ANAND header found at 0x%x in mtd%d, but OOB data read failed (err %d)\n",
@@ -283,7 +288,7 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int
283 return -1; 288 return -1;
284 289
285 if (check_oob) { 290 if (check_oob) {
286 if(mtd->read_oob(mtd, address, mtd->oobsize, 291 if(nftl_read_oob(mtd, address, mtd->oobsize,
287 &retlen, &buf[SECTORSIZE]) < 0) 292 &retlen, &buf[SECTORSIZE]) < 0)
288 return -1; 293 return -1;
289 if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0) 294 if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0)
@@ -311,7 +316,7 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block)
311 struct mtd_info *mtd = nftl->mbd.mtd; 316 struct mtd_info *mtd = nftl->mbd.mtd;
312 317
313 /* Read the Unit Control Information #1 for Wear-Leveling */ 318 /* Read the Unit Control Information #1 for Wear-Leveling */
314 if (mtd->read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 319 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8,
315 8, &retlen, (char *)&uci) < 0) 320 8, &retlen, (char *)&uci) < 0)
316 goto default_uci1; 321 goto default_uci1;
317 322
@@ -351,7 +356,7 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block)
351 goto fail; 356 goto fail;
352 357
353 uci.WearInfo = le32_to_cpu(nb_erases); 358 uci.WearInfo = le32_to_cpu(nb_erases);
354 if (mtd->write_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 359 if (nftl_write_oob(mtd, block * nftl->EraseSize + SECTORSIZE +
355 8, 8, &retlen, (char *)&uci) < 0) 360 8, 8, &retlen, (char *)&uci) < 0)
356 goto fail; 361 goto fail;
357 return 0; 362 return 0;
@@ -383,7 +388,7 @@ static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_b
383 block = first_block; 388 block = first_block;
384 for (;;) { 389 for (;;) {
385 for (i = 0; i < sectors_per_block; i++) { 390 for (i = 0; i < sectors_per_block; i++) {
386 if (mtd->read_oob(mtd, 391 if (nftl_read_oob(mtd,
387 block * nftl->EraseSize + i * SECTORSIZE, 392 block * nftl->EraseSize + i * SECTORSIZE,
388 8, &retlen, (char *)&bci) < 0) 393 8, &retlen, (char *)&bci) < 0)
389 status = SECTOR_IGNORE; 394 status = SECTOR_IGNORE;
@@ -404,7 +409,7 @@ static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_b
404 /* sector not free actually : mark it as SECTOR_IGNORE */ 409 /* sector not free actually : mark it as SECTOR_IGNORE */
405 bci.Status = SECTOR_IGNORE; 410 bci.Status = SECTOR_IGNORE;
406 bci.Status1 = SECTOR_IGNORE; 411 bci.Status1 = SECTOR_IGNORE;
407 mtd->write_oob(mtd, block * 412 nftl_write_oob(mtd, block *
408 nftl->EraseSize + 413 nftl->EraseSize +
409 i * SECTORSIZE, 8, 414 i * SECTORSIZE, 8,
410 &retlen, (char *)&bci); 415 &retlen, (char *)&bci);
@@ -498,7 +503,7 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
498 size_t retlen; 503 size_t retlen;
499 504
500 /* check erase mark. */ 505 /* check erase mark. */
501 if (mtd->read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, 506 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8,
502 &retlen, (char *)&h1) < 0) 507 &retlen, (char *)&h1) < 0)
503 return -1; 508 return -1;
504 509
@@ -513,7 +518,7 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
513 h1.EraseMark = cpu_to_le16(ERASE_MARK); 518 h1.EraseMark = cpu_to_le16(ERASE_MARK);
514 h1.EraseMark1 = cpu_to_le16(ERASE_MARK); 519 h1.EraseMark1 = cpu_to_le16(ERASE_MARK);
515 h1.WearInfo = cpu_to_le32(0); 520 h1.WearInfo = cpu_to_le32(0);
516 if (mtd->write_oob(mtd, 521 if (nftl_write_oob(mtd,
517 block * nftl->EraseSize + SECTORSIZE + 8, 8, 522 block * nftl->EraseSize + SECTORSIZE + 8, 8,
518 &retlen, (char *)&h1) < 0) 523 &retlen, (char *)&h1) < 0)
519 return -1; 524 return -1;
@@ -526,7 +531,7 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
526 SECTORSIZE, 0) != 0) 531 SECTORSIZE, 0) != 0)
527 return -1; 532 return -1;
528 533
529 if (mtd->read_oob(mtd, block * nftl->EraseSize + i, 534 if (nftl_read_oob(mtd, block * nftl->EraseSize + i,
530 16, &retlen, buf) < 0) 535 16, &retlen, buf) < 0)
531 return -1; 536 return -1;
532 if (i == SECTORSIZE) { 537 if (i == SECTORSIZE) {
@@ -557,7 +562,7 @@ static int get_fold_mark(struct NFTLrecord *nftl, unsigned int block)
557 struct nftl_uci2 uci; 562 struct nftl_uci2 uci;
558 size_t retlen; 563 size_t retlen;
559 564
560 if (mtd->read_oob(mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8, 565 if (nftl_read_oob(mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8,
561 8, &retlen, (char *)&uci) < 0) 566 8, &retlen, (char *)&uci) < 0)
562 return 0; 567 return 0;
563 568
@@ -597,10 +602,10 @@ int NFTL_mount(struct NFTLrecord *s)
597 602
598 for (;;) { 603 for (;;) {
599 /* read the block header. If error, we format the chain */ 604 /* read the block header. If error, we format the chain */
600 if (mtd->read_oob(mtd, 605 if (nftl_read_oob(mtd,
601 block * s->EraseSize + 8, 8, 606 block * s->EraseSize + 8, 8,
602 &retlen, (char *)&h0) < 0 || 607 &retlen, (char *)&h0) < 0 ||
603 mtd->read_oob(mtd, 608 nftl_read_oob(mtd,
604 block * s->EraseSize + 609 block * s->EraseSize +
605 SECTORSIZE + 8, 8, 610 SECTORSIZE + 8, 8,
606 &retlen, (char *)&h1) < 0) { 611 &retlen, (char *)&h1) < 0) {