summaryrefslogtreecommitdiff
path: root/cmd/sf.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/sf.c')
-rw-r--r--cmd/sf.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/cmd/sf.c b/cmd/sf.c
index 08e364e1914..b5b7f671fb9 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -197,7 +197,7 @@ static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
return NULL;
}
/* Erase the entire sector */
- if (spi_flash_erase(flash, offset, flash->sector_size))
+ if (spi_flash_erase(flash, read_offset, flash->sector_size))
return "erase";
/* If it's a partial sector, copy the data into the temp-buffer */
if (len != flash->sector_size) {
@@ -205,7 +205,7 @@ static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
ptr = cmp_buf;
}
/* Write one complete sector */
- if (spi_flash_write(flash, offset, flash->sector_size, ptr))
+ if (spi_flash_write(flash, read_offset, flash->sector_size, ptr))
return "write";
return NULL;
@@ -241,7 +241,6 @@ static int spi_flash_update(struct spi_flash *flash, u32 offset,
ulong last_update = get_timer(0);
for (; buf < end && !err_oper; buf += todo, offset += todo) {
- todo = min_t(size_t, end - buf, flash->sector_size);
todo = min_t(size_t, end - buf,
flash->sector_size - (offset % flash->sector_size));
if (get_timer(last_update) > 100) {