summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Stuge <peter@stuge.se>2008-07-02 17:15:47 +0000
committerPeter Stuge <peter@stuge.se>2008-07-02 17:15:47 +0000
commit27c3e2dc23b2df8586eafbe6629ee01a4ad6784b (patch)
tree9f39951428756ac3f830d5510c1bf0591261a1d1
parent4c390c8943ae5d13265d9875e43fbda15583b364 (diff)
downloadast2050-flashrom-27c3e2dc23b2df8586eafbe6629ee01a4ad6784b.zip
ast2050-flashrom-27c3e2dc23b2df8586eafbe6629ee01a4ad6784b.tar.gz
Probe_flash() cleanup for better code readability
Corresponding to flashrom svn r291 and coreboot v2 svn r3407. Signed-off-by: Peter Stuge <peter@stuge.se> Acked-by: Stefan Reinauer <stepan@coresystems.de>
-rw-r--r--flashrom.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/flashrom.c b/flashrom.c
index 63aba1e..f548a91 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -102,18 +102,15 @@ int map_flash_registers(struct flashchip *flash)
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 @@ struct flashchip *probe_flash(struct flashchip *flash, int force)
}
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;
- }
- munmap((void *)bios, size);
+ if (force)
+ break;
- flash++;
+ if (flash->probe(flash) == 1)
+ break;
+
+ munmap((void *)bios, size);
}
- 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)
OpenPOWER on IntegriCloud