From 38a059d6ef1ebb7145a04825fec0ebef1d8a66a7 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Sat, 13 Jun 2009 12:04:03 +0000 Subject: 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 Acked-by: Ronald G. Minnich --- flashrom.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'flashrom.c') diff --git a/flashrom.c b/flashrom.c index 7c3c7f3..f35e9b0 100644 --- a/flashrom.c +++ b/flashrom.c @@ -200,6 +200,11 @@ int read_memmapped(struct flashchip *flash, uint8_t *buf) return 0; } +int min(int a, int b) +{ + return (a < b) ? a : b; +} + char *strcat_realloc(char *dest, const char *src) { dest = realloc(dest, strlen(dest) + strlen(src) + 1); -- cgit v1.1