On Fri, Aug 27, 2010 at 9:51 AM, Ben Gardiner <bengardi...@nanometrics.ca> wrote: > On Thu, Aug 26, 2010 at 5:12 PM, Scott Wood <scottw...@freescale.com> wrote: >>> +{ >>> + if (!mtd->block_isbad) >>> + goto out; >>> + >>> + u32 i, bb_delta = 0; >>> + >>> + for (i = part->offset; i - bb_delta < part->offset + part->size; >>> + i += mtd->erasesize) { >>> + if (mtd->block_isbad(mtd, i)) >>> + bb_delta += mtd->erasesize; >>> + } >>> + >>> + /* >>> + * Absorb bad blocks immeadiately following this >>> + * partition also into the partition, such that >>> + * the next partition starts with a good block. >>> + */ >>> + while (i < mtd->size && mtd->block_isbad(mtd, i)) { >>> + bb_delta += mtd->erasesize; >>> + i += mtd->erasesize; >>> + } >> >> Could this be refactored with get_len_incl_bad()? It should return both the >> updated length and a flag indicating whether it was truncated. > > Yes, I think so. Good point.
I have performed a refactoring but I have reached an impasse: the 'mtdparts spread' command is written for mtd devices whereas the get_len_incl_bad() function is for NAND devices. I extracted a function, mtd_get_len_incl_bad(), to which both the spread_partition and nand_utils.c:get_len_incl_bad() function then delegated. But since a board may have NAND enabled but not MTD_DEVICE (i.e. guruplug) I get link errors sometimes. ATM I'm thinking of leaving the original implementation of get_len_incl_bad in an #else. An alternative is to move 'mtdparts spread' to 'nand mtdparts.spread' -- only OneNAND and NAND devices (currently) have bad_block functions. Best Regards, Ben Gardiner --- Nanometrics Inc. +1 (613) 592-6776 x239 http://www.nanometrics.ca _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot