summaryrefslogtreecommitdiffstats
path: root/sb600spi.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-13 12:04:03 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-13 12:04:03 +0000
commit7aabadaae2d1c6edfc9fdb4a743e86dad47ba4ba (patch)
tree66c9108eda2f0f7129f2ba55b9cb757414d9466a /sb600spi.c
parent27be324db3e5dd789ffaaf4bb51833733b7bbc1b (diff)
downloadflashrom-7aabadaae2d1c6edfc9fdb4a743e86dad47ba4ba.zip
flashrom-7aabadaae2d1c6edfc9fdb4a743e86dad47ba4ba.tar.gz
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 'sb600spi.c')
-rw-r--r--sb600spi.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/sb600spi.c b/sb600spi.c
index 609ad15..10f1cb7 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -41,14 +41,8 @@ uint8_t *sb600_spibar;
int sb600_spi_read(struct flashchip *flash, uint8_t *buf)
{
- int rc = 0, i;
- int total_size = flash->total_size * 1024;
- int page_size = 8;
-
- for (i = 0; i < total_size / page_size; i++)
- spi_nbyte_read(i * page_size, (void *)(buf + i * page_size),
- page_size);
- return rc;
+ /* Maximum read length is 8 bytes. */
+ return spi_read_chunked(flash, buf, 8);
}
uint8_t sb600_read_status_register(void)
OpenPOWER on IntegriCloud