drivers/spi/spi_flash: Pass in spi_slave structure as const to probe functions

Pointer to spi_slave structure can be passed in as const to spi flash
probe functions since the probe functions do not need to modify the
slave properties.

BUG=b:38330715

Change-Id: I956ee777c62dbb811fd6ce2aeb6ae090e1892acd
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://review.coreboot.org/19707
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c
index d062c36..c22bec1 100644
--- a/src/drivers/spi/adesto.c
+++ b/src/drivers/spi/adesto.c
@@ -126,7 +126,7 @@
 	return ret;
 }
 
-int spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_adesto(const struct spi_slave *spi, u8 *idcode,
 			   struct spi_flash *flash)
 {
 	const struct adesto_spi_flash_params *params;
diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c
index cf5a296..e97a362 100644
--- a/src/drivers/spi/amic.c
+++ b/src/drivers/spi/amic.c
@@ -109,7 +109,7 @@
 	return ret;
 }
 
-int spi_flash_probe_amic(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_amic(const struct spi_slave *spi, u8 *idcode,
 			 struct spi_flash *flash)
 {
 	const struct amic_spi_flash_params *params;
diff --git a/src/drivers/spi/atmel.c b/src/drivers/spi/atmel.c
index edc172e..b97f255 100644
--- a/src/drivers/spi/atmel.c
+++ b/src/drivers/spi/atmel.c
@@ -154,7 +154,7 @@
 	return ret;
 }
 
-int spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_atmel(const struct spi_slave *spi, u8 *idcode,
 			  struct spi_flash *flash)
 {
 	const struct atmel_spi_flash_params *params;
diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c
index f5a3af6..ece9810 100644
--- a/src/drivers/spi/eon.c
+++ b/src/drivers/spi/eon.c
@@ -126,7 +126,7 @@
 	return ret;
 }
 
-int spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_eon(const struct spi_slave *spi, u8 *idcode,
 			struct spi_flash *flash)
 {
 	const struct eon_spi_flash_params *params;
diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c
index 0b7173d..f68be8b 100644
--- a/src/drivers/spi/gigadevice.c
+++ b/src/drivers/spi/gigadevice.c
@@ -170,7 +170,7 @@
 	return ret;
 }
 
-int spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_gigadevice(const struct spi_slave *spi, u8 *idcode,
 				struct spi_flash *flash)
 {
 	const struct gigadevice_spi_flash_params *params;
diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c
index 87b6fd7..128d00f 100644
--- a/src/drivers/spi/macronix.c
+++ b/src/drivers/spi/macronix.c
@@ -192,7 +192,7 @@
 	return ret;
 }
 
-int spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_macronix(const struct spi_slave *spi, u8 *idcode,
 			     struct spi_flash *flash)
 {
 	const struct macronix_spi_flash_params *params;
diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c
index a376b6e..de7ad55 100644
--- a/src/drivers/spi/spansion.c
+++ b/src/drivers/spi/spansion.c
@@ -246,7 +246,7 @@
 	return ret;
 }
 
-int spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_spansion(const struct spi_slave *spi, u8 *idcode,
 				struct spi_flash *flash)
 {
 	const struct spansion_spi_flash_params *params;
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 701033a..096d7cd 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -240,7 +240,7 @@
 static struct {
 	const u8 shift;
 	const u8 idcode;
-	int (*probe) (struct spi_slave *spi, u8 *idcode,
+	int (*probe) (const struct spi_slave *spi, u8 *idcode,
 		      struct spi_flash *flash);
 } flashes[] = {
 	/* Keep it sorted by define name */
@@ -282,7 +282,7 @@
 #define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN)
 
 int
-__attribute__((weak)) spi_flash_programmer_probe(struct spi_slave *spi,
+__attribute__((weak)) spi_flash_programmer_probe(const struct spi_slave *spi,
 						 int force,
 						 struct spi_flash *flash)
 {
@@ -290,7 +290,8 @@
 	return -1;
 }
 
-static int __spi_flash_probe(struct spi_slave *spi, struct spi_flash *flash)
+static int __spi_flash_probe(const struct spi_slave *spi,
+				struct spi_flash *flash)
 {
 	int ret, i, shift;
 	u8 idcode[IDCODE_LEN], *idp;
diff --git a/src/drivers/spi/spi_flash_internal.h b/src/drivers/spi/spi_flash_internal.h
index 55d3fa0..b42df59 100644
--- a/src/drivers/spi/spi_flash_internal.h
+++ b/src/drivers/spi/spi_flash_internal.h
@@ -64,25 +64,25 @@
 int spi_flash_cmd_status(const struct spi_flash *flash, u8 *reg);
 
 /* Manufacturer-specific probe functions */
-int spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_spansion(const struct spi_slave *spi, u8 *idcode,
 			     struct spi_flash *flash);
-int spi_flash_probe_amic(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_amic(const struct spi_slave *spi, u8 *idcode,
 			 struct spi_flash *flash);
-int spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_atmel(const struct spi_slave *spi, u8 *idcode,
 			  struct spi_flash *flash);
-int spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_eon(const struct spi_slave *spi, u8 *idcode,
 			struct spi_flash *flash);
-int spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_macronix(const struct spi_slave *spi, u8 *idcode,
 			     struct spi_flash *flash);
-int spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_sst(const struct spi_slave *spi, u8 *idcode,
 			struct spi_flash *flash);
-int spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_stmicro(const struct spi_slave *spi, u8 *idcode,
 			    struct spi_flash *flash);
-int spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_winbond(const struct spi_slave *spi, u8 *idcode,
 			    struct spi_flash *flash);
-int spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_gigadevice(const struct spi_slave *spi, u8 *idcode,
 			       struct spi_flash *flash);
-int spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_adesto(const struct spi_slave *spi, u8 *idcode,
 			   struct spi_flash *flash);
 
 #endif /* SPI_FLASH_INTERNAL_H */
diff --git a/src/drivers/spi/sst.c b/src/drivers/spi/sst.c
index bf21157..5325ef4 100644
--- a/src/drivers/spi/sst.c
+++ b/src/drivers/spi/sst.c
@@ -314,7 +314,7 @@
 	return ret;
 }
 
-int spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_sst(const struct spi_slave *spi, u8 *idcode,
 			struct spi_flash *flash)
 {
 	const struct sst_spi_flash_params *params;
diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c
index b7ceba2..fe8c466 100644
--- a/src/drivers/spi/stmicro.c
+++ b/src/drivers/spi/stmicro.c
@@ -222,7 +222,7 @@
 	return ret;
 }
 
-int spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_stmicro(const struct spi_slave *spi, u8 *idcode,
 			    struct spi_flash *flash)
 {
 	const struct stmicro_spi_flash_params *params;
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c
index c9d4aad..9694f8a 100644
--- a/src/drivers/spi/winbond.c
+++ b/src/drivers/spi/winbond.c
@@ -184,7 +184,7 @@
 	return ret;
 }
 
-int spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode,
+int spi_flash_probe_winbond(const struct spi_slave *spi, u8 *idcode,
 			    struct spi_flash *flash)
 {
 	const struct winbond_spi_flash_params *params;
diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h
index 3b18717..bc0318c 100644
--- a/src/include/spi_flash.h
+++ b/src/include/spi_flash.h
@@ -78,7 +78,7 @@
  * 0 = success
  * non-zero = error
  */
-int spi_flash_programmer_probe(struct spi_slave *spi, int force,
+int spi_flash_programmer_probe(const struct spi_slave *spi, int force,
 				struct spi_flash *flash);
 
 /* All the following functions return 0 on success and non-zero on error. */
diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
index 9f973b9..7780144 100644
--- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
+++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
@@ -280,7 +280,7 @@
  * The size of the flash component is always taken from density field in the
  * SFDP table. FLCOMP.C0DEN is no longer used by the Flash Controller.
  */
-int spi_flash_programmer_probe(struct spi_slave *dev,
+int spi_flash_programmer_probe(const struct spi_slave *dev,
 				int force, struct spi_flash *flash)
 {
 	BOILERPLATE_CREATE_CTX(ctx);
diff --git a/src/soc/mediatek/mt8173/flash_controller.c b/src/soc/mediatek/mt8173/flash_controller.c
index 29a1c2f..ee950b8 100644
--- a/src/soc/mediatek/mt8173/flash_controller.c
+++ b/src/soc/mediatek/mt8173/flash_controller.c
@@ -228,7 +228,7 @@
 	return 0;
 }
 
-int spi_flash_programmer_probe(struct spi_slave *spi,
+int spi_flash_programmer_probe(const struct spi_slave *spi,
 			       int force, struct spi_flash *flash)
 {
 	static int done;
diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c
index effcc80..110c29c 100644
--- a/src/southbridge/intel/common/spi.c
+++ b/src/southbridge/intel/common/spi.c
@@ -899,7 +899,7 @@
 	return 0;
 }
 
-int spi_flash_programmer_probe(struct spi_slave *spi,
+int spi_flash_programmer_probe(const struct spi_slave *spi,
 			       int force, struct spi_flash *flash)
 {
 	uint32_t flcomp;