diff options
Diffstat (limited to 'spi25.c')
-rw-r--r-- | spi25.c | 30 |
1 files changed, 7 insertions, 23 deletions
@@ -652,10 +652,7 @@ int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, lenhere = min(start + len, (i + 1) * area_size) - starthere; for (j = 0; j < lenhere; j += chunksize) { toread = min(chunksize, lenhere - j); - rc = (flash->chip->feature_bits & FEATURE_4BA_SUPPORT) == 0 - ? spi_nbyte_read(flash, starthere + j, buf + starthere - start + j, toread) - : flash->chip->four_bytes_addr_funcs.read_nbyte(flash, starthere + j, - buf + starthere - start + j, toread); + rc = spi_nbyte_read(flash, starthere + j, buf + starthere - start + j, toread); if (rc) break; } @@ -674,7 +671,6 @@ int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize) { - int rc = 0; unsigned int i, j, starthere, lenhere, towrite; /* FIXME: page_size is the wrong variable. We need max_writechunk_size * in struct flashctx to do this properly. All chips using @@ -699,21 +695,16 @@ int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int s /* Length of bytes in the range in this page. */ lenhere = min(start + len, (i + 1) * page_size) - starthere; for (j = 0; j < lenhere; j += chunksize) { + int rc; + towrite = min(chunksize, lenhere - j); - rc = (flash->chip->feature_bits & FEATURE_4BA_SUPPORT) == 0 - ? spi_nbyte_program(flash, starthere + j, buf + starthere - start + j, towrite) - : flash->chip->four_bytes_addr_funcs.program_nbyte(flash, starthere + j, - buf + starthere - start + j, towrite); + rc = spi_nbyte_program(flash, starthere + j, buf + starthere - start + j, towrite); if (rc) - break; - while (spi_read_status_register(flash) & SPI_SR_WIP) - programmer_delay(10); + return rc; } - if (rc) - break; } - return rc; + return 0; } /* @@ -726,18 +717,11 @@ int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int s int spi_chip_write_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { unsigned int i; - int result = 0; for (i = start; i < start + len; i++) { - result = (flash->chip->feature_bits & FEATURE_4BA_SUPPORT) == 0 - ? spi_nbyte_program(flash, i, buf + i - start, 1) - : flash->chip->four_bytes_addr_funcs.program_byte(flash, i, buf[i - start]); - if (result) + if (spi_nbyte_program(flash, i, buf + i - start, 1)) return 1; - while (spi_read_status_register(flash) & SPI_SR_WIP) - programmer_delay(10); } - return 0; } |