diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-12-02 02:41:55 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-12-02 02:41:55 +0000 |
commit | b23b1ebcc9cf04657262f4ef247d457b3f0b1c11 (patch) | |
tree | e3e95db3307e762134af961e11e9ed5cfb500911 /flashrom.c | |
parent | f4e57776eeb9617ccff13895e66a0e11227a3fe3 (diff) | |
download | flashrom-b23b1ebcc9cf04657262f4ef247d457b3f0b1c11.tar.gz flashrom-b23b1ebcc9cf04657262f4ef247d457b3f0b1c11.tar.bz2 flashrom-b23b1ebcc9cf04657262f4ef247d457b3f0b1c11.zip |
Handle erase failure in partial write
Corresponding to flashrom svn r1238.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Diffstat (limited to 'flashrom.c')
-rw-r--r-- | flashrom.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/flashrom.c b/flashrom.c index 7ad9f2dca..629cce29d 100644 --- a/flashrom.c +++ b/flashrom.c @@ -1468,11 +1468,20 @@ int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents, uint8_t /* If everything is OK, don't try another erase function. */ if (!ret) break; - /* FIXME: Reread the whole chip here so we know the current - * chip contents? curcontents might be up to date, but this - * code is only reached if something failed, and then we don't - * know exactly what failed, and how. + /* Write/erase failed, so try to find out what the current chip + * contents are. If no usable erase functions remain, we could + * abort the loop instead of continuing, the effect is the same. + * The only difference is whether the reason for other unusable + * functions is printed or not. If in doubt, verbosity wins. */ + if (flash->read(flash, curcontents, 0, size)) { + /* Now we are truly screwed. Read failed as well. */ + msg_cerr("Can't read anymore!\n"); + /* We have no idea about the flash chip contents, so + * retrying with another erase function is pointless. + */ + break; + } } /* Free the scratchpad. */ free(curcontents); |