summaryrefslogtreecommitdiffstats
path: root/common/ubiformat.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-01-22 09:49:21 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-01-22 09:49:21 +0100
commit5ebdae4863f64a32826c25c6e0d1dfbc1612d904 (patch)
treef7c8ae79050fd00a708bfcda11f6681ebb9a32ce /common/ubiformat.c
parent034637fbd9dfc5cbcffca1f8f392c6ab0dd6f229 (diff)
parent2f9b25f41362e99e2b31684b5c9a1a02abc1ae8b (diff)
downloadbarebox-5ebdae4863f64a32826c25c6e0d1dfbc1612d904.tar.gz
Merge branch 'for-next/misc'
Diffstat (limited to 'common/ubiformat.c')
-rw-r--r--common/ubiformat.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/common/ubiformat.c b/common/ubiformat.c
index 4c5f1f5..f728119 100644
--- a/common/ubiformat.c
+++ b/common/ubiformat.c
@@ -190,6 +190,7 @@ static int flash_image(struct ubiformat_args *args, struct mtd_info *mtd,
int fd, img_ebs, eb, written_ebs = 0, ret = -1, eb_cnt;
off_t st_size;
char *buf = NULL;
+ uint64_t lastprint = 0;
eb_cnt = mtd_num_pebs(mtd);
@@ -229,8 +230,12 @@ static int flash_image(struct ubiformat_args *args, struct mtd_info *mtd,
long long ec;
if (!args->quiet && !args->verbose) {
- printf("\rubiformat: flashing eraseblock %d -- %2u %% complete ",
- eb, (eb + 1) * 100 / eb_cnt);
+ if (is_timeout(lastprint, 300 * MSECOND) ||
+ eb == eb_cnt - 1) {
+ printf("\rubiformat: flashing eraseblock %d -- %2u %% complete ",
+ eb, (eb + 1) * 100 / eb_cnt);
+ lastprint = get_time_ns();
+ }
}
if (si->ec[eb] == EB_BAD)
@@ -325,6 +330,7 @@ static int format(struct ubiformat_args *args, struct mtd_info *mtd,
struct ubi_vtbl_record *vtbl;
int eb1 = -1, eb2 = -1;
long long ec1 = -1, ec2 = -1;
+ uint64_t lastprint = 0;
eb_cnt = mtd_num_pebs(mtd);
@@ -340,8 +346,12 @@ static int format(struct ubiformat_args *args, struct mtd_info *mtd,
long long ec;
if (!args->quiet && !args->verbose) {
- printf("\rubiformat: formatting eraseblock %d -- %2u %% complete ",
- eb, (eb + 1 - start_eb) * 100 / (eb_cnt - start_eb));
+ if (is_timeout(lastprint, 300 * MSECOND) ||
+ eb == eb_cnt - 1) {
+ printf("\rubiformat: formatting eraseblock %d -- %2u %% complete ",
+ eb, (eb + 1 - start_eb) * 100 / (eb_cnt - start_eb));
+ lastprint = get_time_ns();
+ }
}
if (si->ec[eb] == EB_BAD)