--- zzzz-none-000/linux-3.10.107/drivers/mtd/nand/nand_bbt.c 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/drivers/mtd/nand/nand_bbt.c 2021-11-10 11:53:55.000000000 +0000 @@ -468,6 +468,9 @@ int startblock; loff_t from; size_t readlen; +#if defined(CONFIG_AVM_ENHANCED) + unsigned int start_badblocks = mtd->ecc_stats.badblocks; +#endif pr_info("Scanning device for bad blocks\n"); @@ -535,6 +538,72 @@ i += 2; from += (1 << this->bbt_erase_shift); } + +#if defined(CONFIG_AVM_ENHANCED) + if(mtd->ecc_stats.badblocks - start_badblocks) { + int bad_printed = 0; + int bad_start = -1; + + pr_info( "badblock statistics:\n" + "--------------------\n" + " start block = %d\n" + " num blocks = %d\n" + " bad blocks = %u\n", + startblock, + numblocks>>1, + mtd->ecc_stats.badblocks - start_badblocks + ); + + for (i = startblock; i < numblocks;) { + if(this->bbt[i >> 3] & 0x03 << (i & 0x6)) { + if(bad_start == -1) + bad_start = i >> 1; + } else { + if(bad_start != -1) { + if(!bad_printed) { + bad_printed = 1; + + pr_info( "\n" + " >> The following table summarize all badblocks to visualize the distribution" + "\n" + " block [ start | count | size/kB ] (start block, number of blocks)\n" + " --------------------------------- \n"); + } + + pr_info( " block [ %5d | %5d | %7d ]\n", + bad_start, + (i>>1)-bad_start, + (mtd->erasesize/1024) * ((i>>1)-bad_start) + ); + + bad_start = -1; + } + } + + i += 2; + } + if(bad_start != -1) { + if(!bad_printed) { + pr_info( "\n" + " >> The following table summarize all badblocks to visualize the distribution" + "\n" + " block [ start | count | size/kB ] (start block, number of blocks)\n" + " --------------------------------- \n"); + } + + pr_info( " block [ %5d | %5d | %7d ]\n", + bad_start, (i>>1)-bad_start, + (mtd->erasesize/1024) * ((i>>1)-bad_start) + ); + } + + pr_info( " [ ======================= ]\n" + " [ >> %5d | %7d ]\n", + mtd->ecc_stats.badblocks - start_badblocks, + (mtd->erasesize/1024) * (mtd->ecc_stats.badblocks - start_badblocks) + ); + } +#endif return 0; }