diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-07-15 15:28:55 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-07-16 09:04:40 +0200 |
commit | 3b68dbcbfce830bdf91f50943e5ee41463717abf (patch) | |
tree | 230009208fe715a6e89365645f1a9fc0ef508cf7 /common/ubiformat.c | |
parent | 4c216abb0cf5da6f896298fa875cd7bb80dc76b9 (diff) | |
download | barebox-3b68dbcbfce830bdf91f50943e5ee41463717abf.tar.gz barebox-3b68dbcbfce830bdf91f50943e5ee41463717abf.tar.xz |
mtd: peb: Do not mark as bad in mtd_peb_torture()
Both the Kernel and mtd-utils have peb torture functions and both
do not mark the block as bad automatically. Instead, the caller
must mark the block as bad when -EIO is returned from the torture
function. Do the same in barebox. This is necessary as the UBI code
otherwise may mark a block as bad twice: Once indirectly in
mtd_peb_torture() and then directly afterwards.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/ubiformat.c')
-rw-r--r-- | common/ubiformat.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/common/ubiformat.c b/common/ubiformat.c index fe02270b78..4f0df6fd5c 100644 --- a/common/ubiformat.c +++ b/common/ubiformat.c @@ -310,10 +310,13 @@ static int flash_image(struct ubiformat_args *args, struct mtd_info *mtd, goto out_close; err = mtd_peb_torture(mtd, eb); - if (err < 0 && err != -EIO) - goto out_close; - if (err == -EIO && consecutive_bad_check(args, eb)) + if (err == -EIO) { + err = mark_bad(args, mtd, si, eb); + if (err) + goto out_close; + } else if (err) { goto out_close; + } continue; } @@ -426,10 +429,13 @@ static int format(struct ubiformat_args *args, struct mtd_info *mtd, } err = mtd_peb_torture(mtd, eb); - if (err < 0 && err != -EIO) - goto out_free; - if (err == -EIO && consecutive_bad_check(args, eb)) + if (err == -EIO) { + err = mark_bad(args, mtd, si, eb); + if (err) + goto out_free; + } else if (err) { goto out_free; + } continue; |