Show
Ignore:
Timestamp:
07/02/08 19:15:47 (5 months ago)
Author:
stuge
Message:

flashrom: probe_flash() cleanup for better code readability

Signed-off-by: Peter Stuge <peter@…>
Acked-by: Stefan Reinauer <stepan@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/util/flashrom/flashrom.c

    r3394 r3407  
    103103{ 
    104104        volatile uint8_t *bios; 
    105         unsigned long flash_baseaddr, size; 
    106  
    107         while (flash->name != NULL) { 
    108                 if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) { 
    109                         flash++; 
     105        unsigned long flash_baseaddr = 0, size; 
     106 
     107        for (; flash && flash->name; flash++) { 
     108                if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) 
    110109                        continue; 
    111                 } 
    112110                printf_debug("Probing for %s %s, %d KB: ", 
    113111                             flash->vendor, flash->name, flash->total_size); 
    114112                if (!flash->probe && !force) { 
    115113                        printf_debug("failed! flashrom has no probe function for this flash chip.\n"); 
    116                         flash++; 
    117114                        continue; 
    118115                } 
     
    151148                flash->virtual_memory = bios; 
    152149 
    153                 if (force || flash->probe(flash) == 1) { 
    154                         printf("Found chip \"%s %s\" (%d KB) at physical address 0x%lx.\n", 
    155                                flash->vendor, flash->name, flash->total_size, 
    156                                flash_baseaddr); 
    157                         return flash; 
    158                 } 
     150                if (force) 
     151                        break; 
     152 
     153                if (flash->probe(flash) == 1) 
     154                        break; 
     155 
    159156                munmap((void *)bios, size); 
    160  
    161                 flash++; 
    162         } 
    163  
    164         return NULL; 
     157        } 
     158 
     159        if (!flash || !flash->name) 
     160                return NULL; 
     161 
     162        printf("Found chip \"%s %s\" (%d KB) at physical address 0x%lx.\n", 
     163               flash->vendor, flash->name, flash->total_size, flash_baseaddr); 
     164        return flash; 
    165165} 
    166166