spi: Import upstream's per-flash spi master register scheme

Align closer with upstream by introducing a new register dispatch
mechanism and using it to confine global usage behind an API.

V.2: Fix the embedding of mst into the flashctx.
V.3: Just introduce the structures and dispatch mechanism however
     avoid using it here in this patch.
V.4: Sqush in, 'add missing feild in programmer.h' &&
		'cli_classic,dediprog: Fix probe_flash() call sites' &&
		'hack control flow so new dispatch is a nop here'.

BUG=chromium:478356
BRANCH=none
TEST=still builds

Change-Id: I9f3092de8b0a0ea377a53c2b093884ead1eaf13d
Signed-off-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/1657471
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Reviewed-by: Sam McNally <sammc@chromium.org>
Tested-by: Stefan Reinauer <reinauer@google.com>
diff --git a/programmer.c b/programmer.c
index 8dbe08f..1af52b0 100644
--- a/programmer.c
+++ b/programmer.c
@@ -122,6 +122,25 @@
 	buses_supported |= buses;
 }
 
+/* The limit of 4 is totally arbitrary. */
+#define MASTERS_MAX 4
+struct registered_master registered_masters[MASTERS_MAX];
+int registered_master_count = 0;
+
+/* This function copies the struct registered_master parameter. */
+int register_master(const struct registered_master *mst)
+{
+	if (registered_master_count >= MASTERS_MAX) {
+		msg_perr("Tried to register more than %i master "
+			 "interfaces.\n", MASTERS_MAX);
+		return ERROR_FLASHROM_LIMIT;
+	}
+	registered_masters[registered_master_count] = *mst;
+	registered_master_count++;
+
+	return 0;
+}
+
 struct programmer_alias aliases[] = {
 	{ "ec", ALIAS_EC },
 	{ "host", ALIAS_HOST },