Nico Huber has submitted this change. ( https://review.coreboot.org/c/flashrom/+/55122 )
Change subject: cli_classic: replace enum programmer with programmer_entry* ......................................................................
cli_classic: replace enum programmer with programmer_entry*
Change-Id: I4c45f278addeea0d486a316435e8dc15d93cbd70 Signed-off-by: Thomas Heijligen thomas.heijligen@secunet.de Reviewed-on: https://review.coreboot.org/c/flashrom/+/55122 Reviewed-by: Angel Pons th3fanbus@gmail.com Reviewed-by: Nico Huber nico.h@gmx.de Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M cli_classic.c 1 file changed, 12 insertions(+), 8 deletions(-)
Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved Angel Pons: Looks good to me, but someone else must approve
diff --git a/cli_classic.c b/cli_classic.c index ba6885c..4537e1e 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -172,7 +172,8 @@ int read_it = 0, extract_it = 0, write_it = 0, erase_it = 0, verify_it = 0; int dont_verify_it = 0, dont_verify_all = 0, list_supported = 0, operation_specified = 0; struct flashrom_layout *layout = NULL; - enum programmer prog = PROGRAMMER_INVALID; + // enum programmer prog = PROGRAMMER_INVALID; + static const struct programmer_entry *prog = NULL; enum { OPTION_IFD = 0x0100, OPTION_FMAP, @@ -399,15 +400,16 @@ #endif break; case 'p': - if (prog != PROGRAMMER_INVALID) { + if (prog != NULL) { cli_classic_abort_usage("Error: --programmer specified " "more than once. You can separate " "multiple\nparameters for a programmer " "with ",". Please see the man page " "for details.\n"); } - for (prog = 0; prog < programmer_table_size; prog++) { - name = programmer_table[prog]->name; + size_t p; + for (p = 0; p < programmer_table_size; p++) { + name = programmer_table[p]->name; namelen = strlen(name); if (strncmp(optarg, name, namelen) == 0) { switch (optarg[namelen]) { @@ -417,8 +419,10 @@ free(pparam); pparam = NULL; } + prog = programmer_table[p]; break; case '\0': + prog = programmer_table[p]; break; default: /* The continue refers to the @@ -431,7 +435,7 @@ break; } } - if (prog == PROGRAMMER_INVALID) { + if (prog == NULL) { fprintf(stderr, "Error: Unknown programmer "%s". Valid choices are:\n", optarg); list_programmers_linebreak(0, 80, 0); @@ -539,9 +543,9 @@ /* Keep chip around for later usage in case a forced read is requested. */ }
- if (prog == PROGRAMMER_INVALID) { + if (prog == NULL) { if (CONFIG_DEFAULT_PROGRAMMER != PROGRAMMER_INVALID) { - prog = CONFIG_DEFAULT_PROGRAMMER; + prog = programmer_table[CONFIG_DEFAULT_PROGRAMMER]; /* We need to strdup here because we free(pparam) unconditionally later. */ pparam = strdup(CONFIG_DEFAULT_PROGRAMMER_ARGS); msg_pinfo("Using default programmer "%s" with arguments "%s".\n", @@ -562,7 +566,7 @@ /* FIXME: Delay calibration should happen in programmer code. */ myusec_calibrate_delay();
- if (programmer_init(programmer_table[prog], pparam)) { + if (programmer_init(prog, pparam)) { msg_perr("Error: Programmer initialization failed.\n"); ret = 1; goto out_shutdown;