diff options
| author | Viorel Suman <[email protected]> | 2025-09-19 15:01:56 +0800 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-10-14 08:19:43 -0600 |
| commit | 865f6654226b2b933d1971f86eddb8664ca83a3e (patch) | |
| tree | e388aabf9a02d47e6cf640bb36db5a1e7f776f0c /cmd | |
| parent | 3b278dd9e6643a9f75ef108d229c619e197067d0 (diff) | |
cmd: sf: align erase and write on erase block boundary
Align erase and write on erase block boundary in line with how read was
aligned in commit 622b5d35613 ("cmd: sf: Handle unaligned 'update' start
offset").
Fixes: 622b5d35613 ("cmd: sf: Handle unaligned 'update' start offset")
Signed-off-by: Viorel Suman <[email protected]>
Signed-off-by: Ye Li <[email protected]>
Reviewed-by: Peng Fan <[email protected]>
Reviewed-by: Marek Vasut <[email protected]>
Tested-by: Marek Vasut <[email protected]> # R-Car V4H
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/sf.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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) { |
