summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2021-12-21 01:12:04 +0300
committerTom Rini <trini@konsulko.com>2021-12-21 01:12:04 +0300
commit4afab30caea3211032710c4298a8839d3254e7f7 (patch)
tree8318afb8810966aca9fe356dde316c155b7a33ce /tools
parente9d7888da845638f135046d53c25492a8c54e664 (diff)
parent734ad933766f0dbbeafe1b27211686940a5e6d16 (diff)
downloadu-boot-4afab30caea3211032710c4298a8839d3254e7f7.tar.xz
Merge tag 'v2022.01-rc4' into next
Prepare v2022.01-rc4
Diffstat (limited to 'tools')
-rw-r--r--tools/env/fw_env.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index e39c39e23a..3da75be783 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1083,12 +1083,6 @@ static int flash_write_buf(int dev, int fd, void *buf, size_t count)
}
erase.length = erasesize;
- if (DEVTYPE(dev) != MTD_ABSENT) {
- was_locked = ioctl(fd, MEMISLOCKED, &erase);
- /* treat any errors as unlocked flash */
- if (was_locked < 0)
- was_locked = 0;
- }
/* This only runs once on NOR flash and SPI-dataflash */
while (processed < write_total) {
@@ -1108,6 +1102,10 @@ static int flash_write_buf(int dev, int fd, void *buf, size_t count)
if (DEVTYPE(dev) != MTD_ABSENT) {
erase.start = blockstart;
+ was_locked = ioctl(fd, MEMISLOCKED, &erase);
+ /* treat any errors as unlocked flash */
+ if (was_locked < 0)
+ was_locked = 0;
if (was_locked)
ioctl(fd, MEMUNLOCK, &erase);
/* These do not need an explicit erase cycle */
@@ -1163,7 +1161,6 @@ static int flash_flag_obsolete(int dev, int fd, off_t offset)
char tmp = ENV_REDUND_OBSOLETE;
int was_locked; /* flash lock flag */
- was_locked = ioctl(fd, MEMISLOCKED, &erase);
erase.start = DEVOFFSET(dev);
erase.length = DEVESIZE(dev);
/* This relies on the fact, that ENV_REDUND_OBSOLETE == 0 */
@@ -1173,6 +1170,10 @@ static int flash_flag_obsolete(int dev, int fd, off_t offset)
DEVNAME(dev));
return rc;
}
+ was_locked = ioctl(fd, MEMISLOCKED, &erase);
+ /* treat any errors as unlocked flash */
+ if (was_locked < 0)
+ was_locked = 0;
if (was_locked)
ioctl(fd, MEMUNLOCK, &erase);
rc = write(fd, &tmp, sizeof(tmp));