summaryrefslogtreecommitdiff
path: root/wbsio_spi.c
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-06-13 12:04:03 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-06-13 12:04:03 +0000
commit25a91cb722f15b985a18a3155543c8909133e969 (patch)
tree66c9108eda2f0f7129f2ba55b9cb757414d9466a /wbsio_spi.c
parentf060283ec7e2c03cfd4024ec9c291f9b6306564b (diff)
downloadflashrom-25a91cb722f15b985a18a3155543c8909133e969.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. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Ronald G. Minnich <rminnich@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@589 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'wbsio_spi.c')
-rw-r--r--wbsio_spi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/wbsio_spi.c b/wbsio_spi.c
index 554bf2a..dce6631 100644
--- a/wbsio_spi.c
+++ b/wbsio_spi.c
@@ -177,12 +177,12 @@ int wbsio_spi_read(struct flashchip *flash, uint8_t *buf)
{
int size = flash->total_size * 1024;
- if (flash->total_size > 1024) {
+ if (size > 1024 * 1024) {
fprintf(stderr, "%s: Winbond saved on 4 register bits so max chip size is 1024 KB!\n", __func__);
return 1;
}
- memcpy(buf, (const char *)flash->virtual_memory, size);
+ read_memmapped(flash, buf);
return 0;
}