aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/inftlmount.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/inftlmount.c')
-rw-r--r--drivers/mtd/inftlmount.c116
1 files changed, 50 insertions, 66 deletions
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index 104052e774b0..2ff601f816ce 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -53,7 +53,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
53 struct INFTLPartition *ip; 53 struct INFTLPartition *ip;
54 size_t retlen; 54 size_t retlen;
55 55
56 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: find_boot_record(inftl=%p)\n", inftl); 56 pr_debug("INFTL: find_boot_record(inftl=%p)\n", inftl);
57 57
58 /* 58 /*
59 * Assume logical EraseSize == physical erasesize for starting the 59 * Assume logical EraseSize == physical erasesize for starting the
@@ -139,24 +139,20 @@ static int find_boot_record(struct INFTLrecord *inftl)
139 mh->FormatFlags = le32_to_cpu(mh->FormatFlags); 139 mh->FormatFlags = le32_to_cpu(mh->FormatFlags);
140 mh->PercentUsed = le32_to_cpu(mh->PercentUsed); 140 mh->PercentUsed = le32_to_cpu(mh->PercentUsed);
141 141
142#ifdef CONFIG_MTD_DEBUG_VERBOSE 142 pr_debug("INFTL: Media Header ->\n"
143 if (CONFIG_MTD_DEBUG_VERBOSE >= 2) { 143 " bootRecordID = %s\n"
144 printk("INFTL: Media Header ->\n" 144 " NoOfBootImageBlocks = %d\n"
145 " bootRecordID = %s\n" 145 " NoOfBinaryPartitions = %d\n"
146 " NoOfBootImageBlocks = %d\n" 146 " NoOfBDTLPartitions = %d\n"
147 " NoOfBinaryPartitions = %d\n" 147 " BlockMultiplerBits = %d\n"
148 " NoOfBDTLPartitions = %d\n" 148 " FormatFlgs = %d\n"
149 " BlockMultiplerBits = %d\n" 149 " OsakVersion = 0x%x\n"
150 " FormatFlgs = %d\n" 150 " PercentUsed = %d\n",
151 " OsakVersion = 0x%x\n" 151 mh->bootRecordID, mh->NoOfBootImageBlocks,
152 " PercentUsed = %d\n", 152 mh->NoOfBinaryPartitions,
153 mh->bootRecordID, mh->NoOfBootImageBlocks, 153 mh->NoOfBDTLPartitions,
154 mh->NoOfBinaryPartitions, 154 mh->BlockMultiplierBits, mh->FormatFlags,
155 mh->NoOfBDTLPartitions, 155 mh->OsakVersion, mh->PercentUsed);
156 mh->BlockMultiplierBits, mh->FormatFlags,
157 mh->OsakVersion, mh->PercentUsed);
158 }
159#endif
160 156
161 if (mh->NoOfBDTLPartitions == 0) { 157 if (mh->NoOfBDTLPartitions == 0) {
162 printk(KERN_WARNING "INFTL: Media Header sanity check " 158 printk(KERN_WARNING "INFTL: Media Header sanity check "
@@ -200,19 +196,15 @@ static int find_boot_record(struct INFTLrecord *inftl)
200 ip->spareUnits = le32_to_cpu(ip->spareUnits); 196 ip->spareUnits = le32_to_cpu(ip->spareUnits);
201 ip->Reserved0 = le32_to_cpu(ip->Reserved0); 197 ip->Reserved0 = le32_to_cpu(ip->Reserved0);
202 198
203#ifdef CONFIG_MTD_DEBUG_VERBOSE 199 pr_debug(" PARTITION[%d] ->\n"
204 if (CONFIG_MTD_DEBUG_VERBOSE >= 2) { 200 " virtualUnits = %d\n"
205 printk(" PARTITION[%d] ->\n" 201 " firstUnit = %d\n"
206 " virtualUnits = %d\n" 202 " lastUnit = %d\n"
207 " firstUnit = %d\n" 203 " flags = 0x%x\n"
208 " lastUnit = %d\n" 204 " spareUnits = %d\n",
209 " flags = 0x%x\n" 205 i, ip->virtualUnits, ip->firstUnit,
210 " spareUnits = %d\n", 206 ip->lastUnit, ip->flags,
211 i, ip->virtualUnits, ip->firstUnit, 207 ip->spareUnits);
212 ip->lastUnit, ip->flags,
213 ip->spareUnits);
214 }
215#endif
216 208
217 if (ip->Reserved0 != ip->firstUnit) { 209 if (ip->Reserved0 != ip->firstUnit) {
218 struct erase_info *instr = &inftl->instr; 210 struct erase_info *instr = &inftl->instr;
@@ -375,7 +367,7 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
375 * 367 *
376 * Return: 0 when succeed, -1 on error. 368 * Return: 0 when succeed, -1 on error.
377 * 369 *
378 * ToDo: 1. Is it neceressary to check_free_sector after erasing ?? 370 * ToDo: 1. Is it necessary to check_free_sector after erasing ??
379 */ 371 */
380int INFTL_formatblock(struct INFTLrecord *inftl, int block) 372int INFTL_formatblock(struct INFTLrecord *inftl, int block)
381{ 373{
@@ -385,8 +377,7 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)
385 struct mtd_info *mtd = inftl->mbd.mtd; 377 struct mtd_info *mtd = inftl->mbd.mtd;
386 int physblock; 378 int physblock;
387 379
388 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_formatblock(inftl=%p," 380 pr_debug("INFTL: INFTL_formatblock(inftl=%p,block=%d)\n", inftl, block);
389 "block=%d)\n", inftl, block);
390 381
391 memset(instr, 0, sizeof(struct erase_info)); 382 memset(instr, 0, sizeof(struct erase_info));
392 383
@@ -476,30 +467,30 @@ void INFTL_dumptables(struct INFTLrecord *s)
476{ 467{
477 int i; 468 int i;
478 469
479 printk("-------------------------------------------" 470 pr_debug("-------------------------------------------"
480 "----------------------------------\n"); 471 "----------------------------------\n");
481 472
482 printk("VUtable[%d] ->", s->nb_blocks); 473 pr_debug("VUtable[%d] ->", s->nb_blocks);
483 for (i = 0; i < s->nb_blocks; i++) { 474 for (i = 0; i < s->nb_blocks; i++) {
484 if ((i % 8) == 0) 475 if ((i % 8) == 0)
485 printk("\n%04x: ", i); 476 pr_debug("\n%04x: ", i);
486 printk("%04x ", s->VUtable[i]); 477 pr_debug("%04x ", s->VUtable[i]);
487 } 478 }
488 479
489 printk("\n-------------------------------------------" 480 pr_debug("\n-------------------------------------------"
490 "----------------------------------\n"); 481 "----------------------------------\n");
491 482
492 printk("PUtable[%d-%d=%d] ->", s->firstEUN, s->lastEUN, s->nb_blocks); 483 pr_debug("PUtable[%d-%d=%d] ->", s->firstEUN, s->lastEUN, s->nb_blocks);
493 for (i = 0; i <= s->lastEUN; i++) { 484 for (i = 0; i <= s->lastEUN; i++) {
494 if ((i % 8) == 0) 485 if ((i % 8) == 0)
495 printk("\n%04x: ", i); 486 pr_debug("\n%04x: ", i);
496 printk("%04x ", s->PUtable[i]); 487 pr_debug("%04x ", s->PUtable[i]);
497 } 488 }
498 489
499 printk("\n-------------------------------------------" 490 pr_debug("\n-------------------------------------------"
500 "----------------------------------\n"); 491 "----------------------------------\n");
501 492
502 printk("INFTL ->\n" 493 pr_debug("INFTL ->\n"
503 " EraseSize = %d\n" 494 " EraseSize = %d\n"
504 " h/s/c = %d/%d/%d\n" 495 " h/s/c = %d/%d/%d\n"
505 " numvunits = %d\n" 496 " numvunits = %d\n"
@@ -513,7 +504,7 @@ void INFTL_dumptables(struct INFTLrecord *s)
513 s->numvunits, s->firstEUN, s->lastEUN, s->numfreeEUNs, 504 s->numvunits, s->firstEUN, s->lastEUN, s->numfreeEUNs,
514 s->LastFreeEUN, s->nb_blocks, s->nb_boot_blocks); 505 s->LastFreeEUN, s->nb_blocks, s->nb_boot_blocks);
515 506
516 printk("\n-------------------------------------------" 507 pr_debug("\n-------------------------------------------"
517 "----------------------------------\n"); 508 "----------------------------------\n");
518} 509}
519 510
@@ -521,25 +512,25 @@ void INFTL_dumpVUchains(struct INFTLrecord *s)
521{ 512{
522 int logical, block, i; 513 int logical, block, i;
523 514
524 printk("-------------------------------------------" 515 pr_debug("-------------------------------------------"
525 "----------------------------------\n"); 516 "----------------------------------\n");
526 517
527 printk("INFTL Virtual Unit Chains:\n"); 518 pr_debug("INFTL Virtual Unit Chains:\n");
528 for (logical = 0; logical < s->nb_blocks; logical++) { 519 for (logical = 0; logical < s->nb_blocks; logical++) {
529 block = s->VUtable[logical]; 520 block = s->VUtable[logical];
530 if (block > s->nb_blocks) 521 if (block > s->nb_blocks)
531 continue; 522 continue;
532 printk(" LOGICAL %d --> %d ", logical, block); 523 pr_debug(" LOGICAL %d --> %d ", logical, block);
533 for (i = 0; i < s->nb_blocks; i++) { 524 for (i = 0; i < s->nb_blocks; i++) {
534 if (s->PUtable[block] == BLOCK_NIL) 525 if (s->PUtable[block] == BLOCK_NIL)
535 break; 526 break;
536 block = s->PUtable[block]; 527 block = s->PUtable[block];
537 printk("%d ", block); 528 pr_debug("%d ", block);
538 } 529 }
539 printk("\n"); 530 pr_debug("\n");
540 } 531 }
541 532
542 printk("-------------------------------------------" 533 pr_debug("-------------------------------------------"
543 "----------------------------------\n"); 534 "----------------------------------\n");
544} 535}
545 536
@@ -555,7 +546,7 @@ int INFTL_mount(struct INFTLrecord *s)
555 int i; 546 int i;
556 u8 *ANACtable, ANAC; 547 u8 *ANACtable, ANAC;
557 548
558 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_mount(inftl=%p)\n", s); 549 pr_debug("INFTL: INFTL_mount(inftl=%p)\n", s);
559 550
560 /* Search for INFTL MediaHeader and Spare INFTL Media Header */ 551 /* Search for INFTL MediaHeader and Spare INFTL Media Header */
561 if (find_boot_record(s) < 0) { 552 if (find_boot_record(s) < 0) {
@@ -585,7 +576,7 @@ int INFTL_mount(struct INFTLrecord *s)
585 * NOTEXPLORED state. Then at the end we will try to format it and 576 * NOTEXPLORED state. Then at the end we will try to format it and
586 * mark it as free. 577 * mark it as free.
587 */ 578 */
588 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: pass 1, explore each unit\n"); 579 pr_debug("INFTL: pass 1, explore each unit\n");
589 for (first_block = s->firstEUN; first_block <= s->lastEUN; first_block++) { 580 for (first_block = s->firstEUN; first_block <= s->lastEUN; first_block++) {
590 if (s->PUtable[first_block] != BLOCK_NOTEXPLORED) 581 if (s->PUtable[first_block] != BLOCK_NOTEXPLORED)
591 continue; 582 continue;
@@ -717,17 +708,14 @@ int INFTL_mount(struct INFTLrecord *s)
717 logical_block = BLOCK_NIL; 708 logical_block = BLOCK_NIL;
718 } 709 }
719 710
720#ifdef CONFIG_MTD_DEBUG_VERBOSE 711 INFTL_dumptables(s);
721 if (CONFIG_MTD_DEBUG_VERBOSE >= 2)
722 INFTL_dumptables(s);
723#endif
724 712
725 /* 713 /*
726 * Second pass, check for infinite loops in chains. These are 714 * Second pass, check for infinite loops in chains. These are
727 * possible because we don't update the previous pointers when 715 * possible because we don't update the previous pointers when
728 * we fold chains. No big deal, just fix them up in PUtable. 716 * we fold chains. No big deal, just fix them up in PUtable.
729 */ 717 */
730 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: pass 2, validate virtual chains\n"); 718 pr_debug("INFTL: pass 2, validate virtual chains\n");
731 for (logical_block = 0; logical_block < s->numvunits; logical_block++) { 719 for (logical_block = 0; logical_block < s->numvunits; logical_block++) {
732 block = s->VUtable[logical_block]; 720 block = s->VUtable[logical_block];
733 last_block = BLOCK_NIL; 721 last_block = BLOCK_NIL;
@@ -772,12 +760,8 @@ int INFTL_mount(struct INFTLrecord *s)
772 } 760 }
773 } 761 }
774 762
775#ifdef CONFIG_MTD_DEBUG_VERBOSE 763 INFTL_dumptables(s);
776 if (CONFIG_MTD_DEBUG_VERBOSE >= 2) 764 INFTL_dumpVUchains(s);
777 INFTL_dumptables(s);
778 if (CONFIG_MTD_DEBUG_VERBOSE >= 2)
779 INFTL_dumpVUchains(s);
780#endif
781 765
782 /* 766 /*
783 * Third pass, format unreferenced blocks and init free block count. 767 * Third pass, format unreferenced blocks and init free block count.
@@ -785,7 +769,7 @@ int INFTL_mount(struct INFTLrecord *s)
785 s->numfreeEUNs = 0; 769 s->numfreeEUNs = 0;
786 s->LastFreeEUN = BLOCK_NIL; 770 s->LastFreeEUN = BLOCK_NIL;
787 771
788 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: pass 3, format unused blocks\n"); 772 pr_debug("INFTL: pass 3, format unused blocks\n");
789 for (block = s->firstEUN; block <= s->lastEUN; block++) { 773 for (block = s->firstEUN; block <= s->lastEUN; block++) {
790 if (s->PUtable[block] == BLOCK_NOTEXPLORED) { 774 if (s->PUtable[block] == BLOCK_NOTEXPLORED) {
791 printk("INFTL: unreferenced block %d, formatting it\n", 775 printk("INFTL: unreferenced block %d, formatting it\n",