Thomas Heijligen has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/55121 )
Change subject: programmer_init: use struct programmer_entry* ......................................................................
programmer_init: use struct programmer_entry*
Change-Id: Iacf0f25abc94a84c5d52c8d69a3e8640817b060a Signed-off-by: Thomas Heijligen thomas.heijligen@secunet.de --- M cli_classic.c M flashrom.c M libflashrom.c M programmer.h M tests/init_shutdown.c 5 files changed, 14 insertions(+), 14 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/21/55121/1
diff --git a/cli_classic.c b/cli_classic.c index f3ae123..ba6885c 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -562,7 +562,7 @@ /* FIXME: Delay calibration should happen in programmer code. */ myusec_calibrate_delay();
- if (programmer_init(prog, pparam)) { + if (programmer_init(programmer_table[prog], pparam)) { msg_perr("Error: Programmer initialization failed.\n"); ret = 1; goto out_shutdown; diff --git a/flashrom.c b/flashrom.c index 65fa559..faf90c2 100644 --- a/flashrom.c +++ b/flashrom.c @@ -130,15 +130,15 @@ return rc; }
-int programmer_init(enum programmer prog, const char *param) +int programmer_init(const struct programmer_entry *prog, const char *param) { int ret;
- if (prog >= programmer_table_size) { + if (prog == NULL) { msg_perr("Invalid programmer specified!\n"); return -1; } - programmer = programmer_table[prog]; + programmer = prog; /* Initialize all programmer specific data. */ /* Default to unlimited decode sizes. */ max_rom_decode = (const struct decode_sizes) { @@ -1582,7 +1582,7 @@ const char *pname; int pnamelen; int remaining = 0, firstline = 1; - int p; + size_t p; int i;
for (p = 0; p < programmer_table_size; p++) { diff --git a/libflashrom.c b/libflashrom.c index 29a5d2c..d681f9e 100644 --- a/libflashrom.c +++ b/libflashrom.c @@ -119,7 +119,7 @@ */ const char **flashrom_supported_programmers(void) { - int p = 0; + size_t p = 0; const char **supported_programmers = malloc((programmer_table_size + 1) * sizeof(char*));
if (supported_programmers != NULL) { @@ -287,7 +287,7 @@ list_programmers_linebreak(0, 80, 0); return 1; } - return programmer_init(prog, prog_param); + return programmer_init(programmer_table[prog], prog_param); }
/** diff --git a/programmer.h b/programmer.h index fa00376..bac4733 100644 --- a/programmer.h +++ b/programmer.h @@ -178,7 +178,7 @@ extern const struct programmer_entry *programmer_table[]; extern const size_t programmer_table_size;
-int programmer_init(enum programmer prog, const char *param); +int programmer_init(const struct programmer_entry *prog, const char *param); int programmer_shutdown(void);
struct bitbang_spi_master { diff --git a/tests/init_shutdown.c b/tests/init_shutdown.c index abaaf68..85c29e2 100644 --- a/tests/init_shutdown.c +++ b/tests/init_shutdown.c @@ -18,22 +18,22 @@
#include "programmer.h"
-static void run_lifecycle(void **state, enum programmer prog, const char *param) +static void run_lifecycle(void **state, const struct programmer_entry *prog, const char *param) { (void) state; /* unused */
- printf("Testing programmer_init for programmer=%u ...\n", prog); + printf("Testing programmer_init for programmer=%s ...\n", prog->name); assert_int_equal(0, programmer_init(prog, strdup(param))); - printf("... programmer_init for programmer=%u successful\n", prog); + printf("... programmer_init for programmer=%s successful\n", prog->name);
- printf("Testing programmer_shutdown for programmer=%u ...\n", prog); + printf("Testing programmer_shutdown for programmer=%s ...\n", prog->name); assert_int_equal(0, programmer_shutdown()); - printf("... programmer_shutdown for programmer=%u successful\n", prog); + printf("... programmer_shutdown for programmer=%s successful\n", prog->name); }
void dummy_init_and_shutdown_test_success(void **state) { - run_lifecycle(state, PROGRAMMER_DUMMY, "bus=parallel+lpc+fwh+spi"); + run_lifecycle(state, &programmer_dummy, "bus=parallel+lpc+fwh+spi"); }
void linux_spi_init_and_shutdown_test_success(void **state)