sb600spi.c: Make use of new register_spi_master() API

Pass pointers to dynamically allocated data to
register_spi_master(). This way we can avoid mutable globals.

BUG=b:185191942
TEST=builds

Change-Id: Id555dc5e125309883a816e00afb26d7141fd870d
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/54713
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
diff --git a/sb600spi.c b/sb600spi.c
index 80ff0eb..32071b9 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -570,7 +570,7 @@
 	return 0;
 }
 
-static struct spi_master spi_master_sb600 = {
+static const struct spi_master spi_master_sb600 = {
 	.max_data_read = FIFO_SIZE_OLD,
 	.max_data_write = FIFO_SIZE_OLD - 3,
 	.command = sb600_spi_send_command,
@@ -580,7 +580,7 @@
 	.write_aai = default_spi_write_aai,
 };
 
-static struct spi_master spi_master_yangtze = {
+static const struct spi_master spi_master_yangtze = {
 	.max_data_read = FIFO_SIZE_YANGTZE - 3, /* Apparently the big SPI 100 buffer is not a ring buffer. */
 	.max_data_write = FIFO_SIZE_YANGTZE - 3,
 	.command = spi100_spi_send_command,
@@ -590,7 +590,7 @@
 	.write_aai = default_spi_write_aai,
 };
 
-static struct spi_master spi_master_promontory = {
+static const struct spi_master spi_master_promontory = {
 	.max_data_read = MAX_DATA_READ_UNLIMITED,
 	.max_data_write = FIFO_SIZE_YANGTZE - 3,
 	.command = spi100_spi_send_command,
@@ -787,18 +787,14 @@
 	data->sb600_spibar = sb600_spibar;
 
 	register_shutdown(sb600spi_shutdown, data);
-	spi_master_sb600.data = data;
-	spi_master_yangtze.data = data;
-	spi_master_promontory.data = data;
-
 
 	/* Starting with Yangtze the SPI controller got a different interface with a much bigger buffer. */
 	if (amd_gen < CHIPSET_YANGTZE)
-		register_spi_master(&spi_master_sb600, NULL);
+		register_spi_master(&spi_master_sb600, data);
 	else if (amd_gen == CHIPSET_YANGTZE)
-		register_spi_master(&spi_master_yangtze, NULL);
+		register_spi_master(&spi_master_yangtze, data);
 	else
-		register_spi_master(&spi_master_promontory, NULL);
+		register_spi_master(&spi_master_promontory, data);
 
 	return 0;
 }