From 8f287a3e2bc9ea841e36611742d61cf1b33422ab Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Tue, 12 May 2009 15:38:55 +0000 Subject: Use helper functions chip_{read,write}[bwl] to access flash chips The semantic patch I used in r418 to make the original conversion to accessor functions was missing one isomorphism: a[b] <=> *(a+b) The semantic patcher Coccinelle was used to create this patch. Semantic patch follows: @@ typedef uint8_t; expression a; volatile uint8_t *b; @@ - b[a] + *(b + a) @@ expression a; volatile uint8_t *b; @@ - *(b) = (a); + chip_writeb(a, b); @@ volatile uint8_t *b; @@ - *(b) + chip_readb(b) @@ type T; T b; @@ ( chip_readb | chip_writeb ) (..., - (T) - (b) + b ) Corresponding to flashrom svn r498. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Uwe Hermann --- jedec.c | 4 ++-- sst_fwhub.c | 2 +- w39v040c.c | 4 ++-- w39v080fa.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jedec.c b/jedec.c index bfbd93e..b2ab519 100644 --- a/jedec.c +++ b/jedec.c @@ -331,8 +331,8 @@ int write_jedec(struct flashchip *flash, uint8_t *buf) erase_chip_jedec(flash); // dumb check if erase was successful. for (i = 0; i < total_size; i++) { - if (bios[i] != (uint8_t) 0xff) { - printf("ERASE FAILED @%d, val %02x!\n", i, bios[i]); + if (chip_readb(bios + i) != (uint8_t) 0xff) { + printf("ERASE FAILED @%d, val %02x!\n", i, chip_readb(bios + i)); return -1; } } diff --git a/sst_fwhub.c b/sst_fwhub.c index 0bf2d4d..3b74a95 100644 --- a/sst_fwhub.c +++ b/sst_fwhub.c @@ -122,7 +122,7 @@ int erase_sst_fwhub(struct flashchip *flash) // dumb check if erase was successful. for (i = 0; i < total_size; i++) { - if (bios[i] != 0xff) { + if (chip_readb(bios + i) != 0xff) { printf("ERASE FAILED!\n"); return -1; } diff --git a/w39v040c.c b/w39v040c.c index f631d33..e7a2eb1 100644 --- a/w39v040c.c +++ b/w39v040c.c @@ -67,8 +67,8 @@ int erase_w39v040c(struct flashchip *flash) erase_sector_jedec(flash->virtual_memory, i); for (i = 0; i < total_size; i++) - if (0xff != bios[i]) { - printf("ERASE FAILED at 0x%08x! Expected=0xff, Read=0x%02x\n", i, bios[i]); + if (0xff != chip_readb(bios + i)) { + printf("ERASE FAILED at 0x%08x! Expected=0xff, Read=0x%02x\n", i, chip_readb(bios + i)); return -1; } diff --git a/w39v080fa.c b/w39v080fa.c index ba32add..7b827f8 100644 --- a/w39v080fa.c +++ b/w39v080fa.c @@ -180,8 +180,8 @@ int erase_winbond_fwhub(struct flashchip *flash) printf("\n"); for (i = 0; i < total_size; i++) { - if (bios[i] != 0xff) { - fprintf(stderr, "Error: Flash chip erase failed at 0x%08x(0x%02x)\n", i, bios[i]); + if (chip_readb(bios + i) != 0xff) { + fprintf(stderr, "Error: Flash chip erase failed at 0x%08x(0x%02x)\n", i, chip_readb(bios + i)); return -1; } } -- cgit v1.1