programmer_init: use struct programmer_entry*

Change-Id: Iacf0f25abc94a84c5d52c8d69a3e8640817b060a
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/55121
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71378
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/cli_classic.c b/cli_classic.c
index 5ebc6ea..41d456c 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -458,7 +458,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 ca271ca..6515b20 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -136,15 +136,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) {
diff --git a/libflashrom.c b/libflashrom.c
index 5402978..f8c90e0 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -143,7 +143,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 af7d500..ba084a7 100644
--- a/programmer.h
+++ b/programmer.h
@@ -163,7 +163,7 @@
 extern const struct programmer_entry *const 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 {