Nico Huber has submitted this change. ( https://review.coreboot.org/c/flashrom/+/55119 )
Change subject: flashrom.c: replace enum programmer with struct programmer_entry* ......................................................................
flashrom.c: replace enum programmer with struct programmer_entry*
Change-Id: I478c56354d5f482010bfe1560489700bc889717a Signed-off-by: Thomas Heijligen thomas.heijligen@secunet.de Reviewed-on: https://review.coreboot.org/c/flashrom/+/55119 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Nico Huber nico.h@gmx.de --- M flashrom.c 1 file changed, 12 insertions(+), 12 deletions(-)
Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved
diff --git a/flashrom.c b/flashrom.c index c036fea..0476b3d 100644 --- a/flashrom.c +++ b/flashrom.c @@ -43,7 +43,7 @@ const char flashrom_version[] = FLASHROM_VERSION; const char *chip_to_probe = NULL;
-static enum programmer programmer = PROGRAMMER_INVALID; +static const struct programmer_entry *programmer = NULL; static const char *programmer_param = NULL;
/* @@ -138,7 +138,7 @@ msg_perr("Invalid programmer specified!\n"); return -1; } - programmer = prog; + programmer = programmer_table[prog]; /* Initialize all programmer specific data. */ /* Default to unlimited decode sizes. */ max_rom_decode = (const struct decode_sizes) { @@ -155,8 +155,8 @@ programmer_may_write = 1;
programmer_param = param; - msg_pdbg("Initializing %s programmer\n", programmer_table[programmer]->name); - ret = programmer_table[programmer]->init(); + msg_pdbg("Initializing %s programmer\n", programmer->name); + ret = programmer->init(); if (programmer_param && strlen(programmer_param)) { if (ret != 0) { /* It is quite possible that any unhandled programmer parameter would have been valid, @@ -200,7 +200,7 @@
void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len) { - void *ret = programmer_table[programmer]->map_flash_region(descr, phys_addr, len); + void *ret = programmer->map_flash_region(descr, phys_addr, len); msg_gspew("%s: mapping %s from 0x%0*" PRIxPTR " to 0x%0*" PRIxPTR "\n", __func__, descr, PRIxPTR_WIDTH, phys_addr, PRIxPTR_WIDTH, (uintptr_t) ret); return ret; @@ -208,7 +208,7 @@
void programmer_unmap_flash_region(void *virt_addr, size_t len) { - programmer_table[programmer]->unmap_flash_region(virt_addr, len); + programmer->unmap_flash_region(virt_addr, len); msg_gspew("%s: unmapped 0x%0*" PRIxPTR "\n", __func__, PRIxPTR_WIDTH, (uintptr_t)virt_addr); }
@@ -256,7 +256,7 @@ void programmer_delay(unsigned int usecs) { if (usecs > 0) - programmer_table[programmer]->delay(usecs); + programmer->delay(usecs); }
int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, @@ -840,12 +840,12 @@ flash->chip->vendor, flash->chip->name, flash->chip->total_size, tmp); free(tmp); #if CONFIG_INTERNAL == 1 - if (programmer_table[programmer]->map_flash_region == physmap) + if (programmer->map_flash_region == physmap) msg_cinfo("mapped at physical address 0x%0*" PRIxPTR ".\n", PRIxPTR_WIDTH, flash->physical_memory); else #endif - msg_cinfo("on %s.\n", programmer_table[programmer]->name); + msg_cinfo("on %s.\n", programmer->name);
/* Flash registers may more likely not be mapped if the chip was forced. * Lock info may be stored in registers, so avoid lock info printing. */ @@ -1548,7 +1548,7 @@ { msg_gerr("Good, writing to the flash chip apparently didn't do anything.\n"); #if CONFIG_INTERNAL == 1 - if (programmer == PROGRAMMER_INTERNAL) + if (programmer == &programmer_internal) msg_gerr("This means we have to add special support for your board, programmer or flash\n" "chip. Please report this on IRC at chat.freenode.net (channel #flashrom) or\n" "mail flashrom@flashrom.org, thanks!\n" @@ -1566,7 +1566,7 @@ { msg_gerr("Your flash chip is in an unknown state.\n"); #if CONFIG_INTERNAL == 1 - if (programmer == PROGRAMMER_INTERNAL) + if (programmer == &programmer_internal) msg_gerr("Get help on IRC at chat.freenode.net (channel #flashrom) or\n" "mail flashrom@flashrom.org with the subject "FAILED: <your board name>"!\n" "-------------------------------------------------------------------------------\n" @@ -2060,7 +2060,7 @@ }
#if CONFIG_INTERNAL == 1 - if (programmer == PROGRAMMER_INTERNAL && cb_check_image(newcontents, flash_size) < 0) { + if (programmer == &programmer_internal && cb_check_image(newcontents, flash_size) < 0) { if (flashctx->flags.force_boardmismatch) { msg_pinfo("Proceeding anyway because user forced us to.\n"); } else {