From 14da740cec46d151e813905e449e7ff21e85c01f Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 26 Nov 2009 11:38:45 +0200 Subject: ubiformat: fix --erase-counter handling The --erase-counter option did not work and this was reproted by Darwin Rambo Signed-off-by: Artem Bityutskiy --- ubi-utils/src/ubiformat.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ubi-utils/src/ubiformat.c b/ubi-utils/src/ubiformat.c index 62375a6..681ea30 100644 --- a/ubi-utils/src/ubiformat.c +++ b/ubi-utils/src/ubiformat.c @@ -506,13 +506,12 @@ static int flash_image(const struct mtd_dev_info *mtd, struct ubi_scan_info *si) goto out_close; } - - if (si->ec[eb] <= EC_MAX) + if (args.override_ec) + ec = args.ec; + else if (si->ec[eb] <= EC_MAX) ec = si->ec[eb] + 1; - else if (!args.override_ec) - ec = si->mean_ec; else - ec = args.ec; + ec = si->mean_ec; if (args.verbose) { printf(", change EC to %lld", ec); @@ -590,12 +589,12 @@ static int format(const struct mtd_dev_info *mtd, const struct ubigen_info *ui, if (si->ec[eb] == EB_BAD) continue; - if (si->ec[eb] <= EC_MAX) + if (args.override_ec) + ec = args.ec; + else if (si->ec[eb] <= EC_MAX) ec = si->ec[eb] + 1; - else if (!args.override_ec) - ec = si->mean_ec; else - ec = args.ec; + ec = si->mean_ec; ubigen_init_ec_hdr(ui, hdr, ec); if (args.verbose) { -- cgit v1.2.3