summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2015-04-28 07:28:43 -0400
committerTom Rini <trini@konsulko.com>2015-04-28 07:28:43 -0400
commitcc555bd4f40a652471df4a3621d45ee57df0ca11 (patch)
tree6f1f21e7d5cf9cb29d0169aa4377eea9c0981f98 /common
parent86e6f7eaa15f0aca03bb7c961902563348c2dd05 (diff)
parentc650ca7b4c160193791dc7a52381c71c6a29e871 (diff)
downloadtalos-obmc-uboot-cc555bd4f40a652471df4a3621d45ee57df0ca11.tar.gz
talos-obmc-uboot-cc555bd4f40a652471df4a3621d45ee57df0ca11.zip
Merge branch 'master' of git://git.denx.de/u-boot-spi
Diffstat (limited to 'common')
-rw-r--r--common/cmd_sf.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 6aabf39302..342021df97 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -164,6 +164,8 @@ static int do_spi_flash_probe(int argc, char * const argv[])
static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
size_t len, const char *buf, char *cmp_buf, size_t *skipped)
{
+ char *ptr = (char *)buf;
+
debug("offset=%#x, sector_size=%#x, len=%#zx\n",
offset, flash->sector_size, len);
/* Read the entire sector so to allow for rewriting */
@@ -179,16 +181,14 @@ static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
/* Erase the entire sector */
if (spi_flash_erase(flash, offset, flash->sector_size))
return "erase";
- /* Write the initial part of the block from the source */
- if (spi_flash_write(flash, offset, len, buf))
- return "write";
- /* If it's a partial sector, rewrite the existing part */
+ /* If it's a partial sector, copy the data into the temp-buffer */
if (len != flash->sector_size) {
- /* Rewrite the original data to the end of the sector */
- if (spi_flash_write(flash, offset + len,
- flash->sector_size - len, &cmp_buf[len]))
- return "write";
+ memcpy(cmp_buf, buf, len);
+ ptr = cmp_buf;
}
+ /* Write one complete sector */
+ if (spi_flash_write(flash, offset, flash->sector_size, ptr))
+ return "write";
return NULL;
}
OpenPOWER on IntegriCloud