[U-Boot] [PATCH v4 4/4] mtdparts: new add.spread: add part skipping bad blocks
Ben Gardiner
bengardiner at nanometrics.ca
Fri Aug 27 15:52:56 CEST 2010
On Thu, Aug 26, 2010 at 6:26 PM, Scott Wood <scottwood at freescale.com> wrote:
> On Mon, Aug 09, 2010 at 04:44:00PM -0400, Ben Gardiner wrote:
>> +#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
>> + s = strchr(argv[1], '.');
>> +
>> + if (get_mtd_info(dev->id->type, dev->id->num, &mtd))
>> + return 1;
>> +#endif
>> +
>> if ((dev_tmp = device_find(dev->id->type, dev->id->num)) == NULL) {
>> +#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
>> + if (s && !strcmp(s, ".spread")) {
>
> No need for the strchr, just do "if (!strcmp(&argv[1][3], ".spread"))".
Thanks for pointing that out -- I see it now.
>> + p = list_entry(dev->parts.next,
>> + struct part_info, link);
>> + spread_partition(mtd, p, &next_offset);
>> +
>> + debug("increased %s to %d bytes\n", p->name,
>> + p->size);
>> + }
>> +#endif
>> device_add(dev);
>> } else {
>> /* merge new partition with existing ones*/
>> p = list_entry(dev->parts.next, struct part_info, link);
>> +#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
>> + if (s && !strcmp(s, ".spread")) {
>> + spread_partition(mtd, p, &next_offset);
>> +
>> + debug("increased %s to %d bytes\n", p->name,
>> + p->size);
>> + }
>> +#endif
>
> Don't duplicate this on both sides of the "if"; instead do something like:
>
> p = list_entry(dev->parts.next...);
>
> if (!strcmp(&argv[1][3], ".spread"))
> spread_partition(mtd, p, &next_offset);
>
> if ((dev_tmp = ...) {
> device_add(dev);
> } else if (part_add(dev_tmp, p)) {
> device_del(dev);
> return 1;
> }
Ok, I'll give it a shot.
Thank you again for your review and detailed comments. I appreciate
you taking the time to help me get these patches prepared. I will
integrate your comments on patches 2-4 shortly.
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca
More information about the U-Boot
mailing list