flashrom: probe_flash() cleanup for better code readability
Signed-off-by: Peter Stuge <peter@stuge.se>
|
|
|
|
| 102 | 102 | struct flashchip *probe_flash(struct flashchip *flash, int force) |
| 103 | 103 | { |
| 104 | 104 | volatile uint8_t *bios; |
| 105 | | unsigned long flash_baseaddr, size; |
| | 105 | unsigned long flash_baseaddr = 0, size; |
| 106 | 106 | |
| 107 | | while (flash->name != NULL) { |
| 108 | | if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) { |
| 109 | | flash++; |
| | 107 | for (; flash && flash->name; flash++) { |
| | 108 | if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) |
| 110 | 109 | continue; |
| 111 | | } |
| 112 | 110 | printf_debug("Probing for %s %s, %d KB: ", |
| 113 | 111 | flash->vendor, flash->name, flash->total_size); |
| 114 | 112 | if (!flash->probe && !force) { |
| 115 | 113 | printf_debug("failed! flashrom has no probe function for this flash chip.\n"); |
| 116 | | flash++; |
| 117 | 114 | continue; |
| 118 | 115 | } |
| 119 | 116 | |
| … |
… |
|
| 150 | 147 | } |
| 151 | 148 | flash->virtual_memory = bios; |
| 152 | 149 | |
| 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 | |
| 159 | 156 | munmap((void *)bios, size); |
| 160 | | |
| 161 | | flash++; |
| 162 | 157 | } |
| 163 | 158 | |
| 164 | | return NULL; |
| | 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; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | int verify_flash(struct flashchip *flash, uint8_t *buf) |