[U-Boot] [PATCH 2/4] mtdparts: show net size in mtdparts list

Stefan Roese
2010-06-02T07:15:07Z

On Tuesday 01 June 2010 22:23:45 Ben Gardiner wrote:
> This patch adds an additional column to the output of list_partitions. The
> additional column will contain the net size and a '(!)' beside it if the
> net size is not equal to the partition size.

Please find some comments below.

> Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
> ---
> common/cmd_mtdparts.c | 28 ++++++++++++++++++++++++++--
> 1 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
> index 7a9768f..24d27b9 100644
> --- a/common/cmd_mtdparts.c
> +++ b/common/cmd_mtdparts.c
> @@ -1213,6 +1213,23 @@ static int generate_mtdparts_save(char *buf, u32
> buflen) return ret;
> }
>
> +/** get the net size (w/o bad blocks) of the given partition
> + * @param mtd the mtd info
> + * @param part the partition
> + * @param net_size the calculated net size of this partition (output)
> + */
> +static void net_part_size(struct mtd_info *mtd, struct part_info *part,
> u32 *net_size)
> +{
> + u32 i, bb_delta = 0;
> +
> + for(i = 0; i < part->size; i += mtd->erasesize) {
> + if(mtd->block_isbad(mtd, part->offset + i))

Please add spaces after "for" and "if".

> + bb_delta += mtd->erasesize;
> + }
> +
> + *net_size = part->size - bb_delta;
> +}

Why don't you return net_size instead:

static u32 net_part_size(struct mtd_info *mtd, struct part_info *part)
{
...
return part->size - bb_delta;
}

Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de