diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-06-13 12:04:03 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-06-13 12:04:03 +0000 |
commit | 38a059d6ef1ebb7145a04825fec0ebef1d8a66a7 (patch) | |
tree | 66c9108eda2f0f7129f2ba55b9cb757414d9466a /it87spi.c | |
parent | 8b2f46b878a952a0ea0869624636cb4d6f5fa8c1 (diff) | |
download | flashrom-38a059d6ef1ebb7145a04825fec0ebef1d8a66a7.tar.gz flashrom-38a059d6ef1ebb7145a04825fec0ebef1d8a66a7.tar.bz2 flashrom-38a059d6ef1ebb7145a04825fec0ebef1d8a66a7.zip |
Every SPI host controller implemented its own way to read flash chips
This was partly due to a design problem in the abstraction layer.
There should be exactly two different functions for reading SPI chips:
- memory mapped reads
- SPI command reads.
Each of them should be contained in a separate function, optionally
taking parameters where needed.
This patch solves the problems mentioned above, shortens the code and
makes the code logic a lot more obvious.
Since open-coding the min() function leads to errors, include it in this
patch as well.
Corresponding to flashrom svn r589.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'it87spi.c')
-rw-r--r-- | it87spi.c | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -260,18 +260,12 @@ int it8716f_spi_chip_write_1(struct flashchip *flash, uint8_t *buf) int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf) { int total_size = 1024 * flash->total_size; - int i; fast_spi = 0; if ((programmer == PROGRAMMER_IT87SPI) || (total_size > 512 * 1024)) { - for (i = 0; i < total_size; i += 3) { - int toread = 3; - if (total_size - i < toread) - toread = total_size - i; - spi_nbyte_read(i, buf + i, toread); - } + spi_read_chunked(flash, buf, 3); } else { - memcpy(buf, (const char *)flash->virtual_memory, total_size); + read_memmapped(flash, buf); } return 0; |