Author: hailfinger
Date: 2009-05-12 17:38:55 +0200 (Tue, 12 May 2009)
New Revision: 498

Modified:
   trunk/jedec.c
   trunk/sst_fwhub.c
   trunk/w39v040c.c
   trunk/w39v080fa.c
Log:
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
 )

Signed-off-by: Carl-Daniel Hailfinger <[email protected]>
Acked-by: Uwe Hermann <[email protected]>


Modified: trunk/jedec.c
===================================================================
--- trunk/jedec.c       2009-05-12 14:06:04 UTC (rev 497)
+++ trunk/jedec.c       2009-05-12 15:38:55 UTC (rev 498)
@@ -331,8 +331,8 @@
        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;
                }
        }

Modified: trunk/sst_fwhub.c
===================================================================
--- trunk/sst_fwhub.c   2009-05-12 14:06:04 UTC (rev 497)
+++ trunk/sst_fwhub.c   2009-05-12 15:38:55 UTC (rev 498)
@@ -122,7 +122,7 @@
 
        // 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;
                }

Modified: trunk/w39v040c.c
===================================================================
--- trunk/w39v040c.c    2009-05-12 14:06:04 UTC (rev 497)
+++ trunk/w39v040c.c    2009-05-12 15:38:55 UTC (rev 498)
@@ -67,8 +67,8 @@
                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;
                }
 

Modified: trunk/w39v080fa.c
===================================================================
--- trunk/w39v080fa.c   2009-05-12 14:06:04 UTC (rev 497)
+++ trunk/w39v080fa.c   2009-05-12 15:38:55 UTC (rev 498)
@@ -180,8 +180,8 @@
        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;
                }
        }


-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to