Author: stuge
Date: 2008-07-02 19:15:47 +0200 (Wed, 02 Jul 2008)
New Revision: 3407

Modified:
   trunk/util/flashrom/flashrom.c
Log:
flashrom: probe_flash() cleanup for better code readability

Signed-off-by: Peter Stuge <[EMAIL PROTECTED]>
Acked-by: Stefan Reinauer <[EMAIL PROTECTED]>


Modified: trunk/util/flashrom/flashrom.c
===================================================================
--- trunk/util/flashrom/flashrom.c      2008-07-02 13:33:09 UTC (rev 3406)
+++ trunk/util/flashrom/flashrom.c      2008-07-02 17:15:47 UTC (rev 3407)
@@ -102,18 +102,15 @@
 struct flashchip *probe_flash(struct flashchip *flash, int force)
 {
        volatile uint8_t *bios;
-       unsigned long flash_baseaddr, size;
+       unsigned long flash_baseaddr = 0, size;
 
-       while (flash->name != NULL) {
-               if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) {
-                       flash++;
+       for (; flash && flash->name; flash++) {
+               if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0)
                        continue;
-               }
                printf_debug("Probing for %s %s, %d KB: ",
                             flash->vendor, flash->name, flash->total_size);
                if (!flash->probe && !force) {
                        printf_debug("failed! flashrom has no probe function 
for this flash chip.\n");
-                       flash++;
                        continue;
                }
 
@@ -150,18 +147,21 @@
                }
                flash->virtual_memory = bios;
 
-               if (force || flash->probe(flash) == 1) {
-                       printf("Found chip \"%s %s\" (%d KB) at physical 
address 0x%lx.\n",
-                              flash->vendor, flash->name, flash->total_size,
-                              flash_baseaddr);
-                       return flash;
-               }
+               if (force)
+                       break;
+
+               if (flash->probe(flash) == 1)
+                       break;
+
                munmap((void *)bios, size);
-
-               flash++;
        }
 
-       return NULL;
+       if (!flash || !flash->name)
+               return NULL;
+
+       printf("Found chip \"%s %s\" (%d KB) at physical address 0x%lx.\n",
+              flash->vendor, flash->name, flash->total_size, flash_baseaddr);
+       return flash;
 }
 
 int verify_flash(struct flashchip *flash, uint8_t *buf)


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

Reply via email to