bitbang: Extend register_spi_bitbang_master() API with spi data

This allows the users of register_spi_bitbang_master() API to pass
their spi data into the API, and then the data can go further, into
register_spi_master() API.

flashrom-stable: Removed unnecessary if.

Change-Id: I13e83ae74dbc3a3e79c84d1463683d360ff47bc0
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/54990
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/73267
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/bitbang_spi.c b/bitbang_spi.c
index 91f48a9..ef9e77c 100644
--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -23,6 +23,7 @@
 
 struct bitbang_spi_master_data {
 	const struct bitbang_spi_master *mst;
+	void *spi_data;
 };
 
 /* Note that CS# is active low, so val=0 means the chip is active. */
@@ -93,7 +94,7 @@
 	return 0;
 }
 
-int register_spi_bitbang_master(const struct bitbang_spi_master *master)
+int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *spi_data)
 {
 	struct spi_master mst = spi_master_bitbang;
 	/* If someone forgot to initialize a bitbang function, we catch it here. */
@@ -113,6 +114,7 @@
 	}
 
 	data->mst = master;
+	data->spi_data = spi_data;
 	register_spi_master(&mst, data);
 
 	/* Only mess with the bus if we're sure nobody else uses it. */
diff --git a/developerbox_spi.c b/developerbox_spi.c
index e186240..c327043 100644
--- a/developerbox_spi.c
+++ b/developerbox_spi.c
@@ -155,7 +155,7 @@
 	if (register_shutdown(developerbox_spi_shutdown, NULL))
 		goto err_exit;
 
-	if (register_spi_bitbang_master(&bitbang_spi_master_cp210x))
+	if (register_spi_bitbang_master(&bitbang_spi_master_cp210x, NULL))
 		goto err_exit;
 
 	return 0;
diff --git a/include/programmer.h b/include/programmer.h
index b349e32..527eeb3 100644
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -273,7 +273,7 @@
 #endif
 
 /* bitbang_spi.c */
-int register_spi_bitbang_master(const struct bitbang_spi_master *master);
+int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *spi_data);
 
 
 /* flashrom.c */
diff --git a/mcp6x_spi.c b/mcp6x_spi.c
index dd76e60..bf09628 100644
--- a/mcp6x_spi.c
+++ b/mcp6x_spi.c
@@ -150,7 +150,7 @@
 		 (status >> MCP6X_SPI_GRANT) & 0x1);
 	mcp_gpiostate = status & 0xff;
 
-	if (register_spi_bitbang_master(&bitbang_spi_master_mcp6x)) {
+	if (register_spi_bitbang_master(&bitbang_spi_master_mcp6x, NULL)) {
 		/* This should never happen. */
 		msg_perr("MCP6X bitbang SPI master init failed!\n");
 		return 1;
diff --git a/nicintel_spi.c b/nicintel_spi.c
index b89dc09..91ae02f 100644
--- a/nicintel_spi.c
+++ b/nicintel_spi.c
@@ -294,7 +294,7 @@
 				return 1;
 	}
 
-	if (register_spi_bitbang_master(&bitbang_spi_master_nicintel))
+	if (register_spi_bitbang_master(&bitbang_spi_master_nicintel, NULL))
 		return 1;
 
 	return 0;
diff --git a/ogp_spi.c b/ogp_spi.c
index 18e6514..ea1f6b2 100644
--- a/ogp_spi.c
+++ b/ogp_spi.c
@@ -133,7 +133,7 @@
 	if (ogp_spibar == ERROR_PTR)
 		return 1;
 
-	if (register_spi_bitbang_master(&bitbang_spi_master_ogp))
+	if (register_spi_bitbang_master(&bitbang_spi_master_ogp, NULL))
 		return 1;
 
 	return 0;
diff --git a/pony_spi.c b/pony_spi.c
index fba7fb7..22f5f02 100644
--- a/pony_spi.c
+++ b/pony_spi.c
@@ -224,7 +224,7 @@
 		return 1;
 	}
 
-	if (register_spi_bitbang_master(&bitbang_spi_master_pony)) {
+	if (register_spi_bitbang_master(&bitbang_spi_master_pony, NULL)) {
 		return 1;
 	}
 	return 0;
diff --git a/rayer_spi.c b/rayer_spi.c
index 12ff019..5267a06 100644
--- a/rayer_spi.c
+++ b/rayer_spi.c
@@ -230,7 +230,7 @@
 	if (pinout->preinit)
 		pinout->preinit(pinout);
 
-	if (register_spi_bitbang_master(&bitbang_spi_master_rayer))
+	if (register_spi_bitbang_master(&bitbang_spi_master_rayer, NULL))
 		return 1;
 
 	return 0;