summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-09-09 23:14:06 +1000
committerThomas Heijligen <src@posteo.de>2023-03-01 09:43:17 +0000
commit119d0e5236df69702c5ac5be593c4aa683e2b35d (patch)
tree98ee5bafbbdc4bb8346594ba2f49f76de31830c6
parent263d50c7d1f149c5d0f14512a1f6251b2a4e878f (diff)
downloadflashrom-119d0e5236df69702c5ac5be593c4aa683e2b35d.tar.gz
flashrom-119d0e5236df69702c5ac5be593c4aa683e2b35d.tar.bz2
flashrom-119d0e5236df69702c5ac5be593c4aa683e2b35d.zip
spi: Make 'default_spi_send_multicommand' the default unless defined
A NULL func pointer is necessary and sufficient for the condition `NULL func pointer => default_spi_send_multicommand' as to not need this explicit specification of 'default'. Therefore drop the explicit need to specify the 'default_spi_send_multicommand' callback function pointer in the spi_master struct. This is a reasonable default for every other driver in the tree with only a few exceptions. This simplifies the code and driver development. Change-Id: I6cc24bf982da3d5251d391eb397db43dd10280e8 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/67481 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
-rw-r--r--asm106x.c1
-rw-r--r--bitbang_spi.c1
-rw-r--r--buspirate_spi.c1
-rw-r--r--ch341a_spi.c1
-rw-r--r--ch347_spi.c1
-rw-r--r--dediprog.c1
-rw-r--r--digilent_spi.c1
-rw-r--r--dirtyjtag_spi.c1
-rw-r--r--dummyflasher.c1
-rw-r--r--it87spi.c1
-rw-r--r--jlink_spi.c1
-rw-r--r--linux_spi.c1
-rw-r--r--mediatek_i2c_spi.c1
-rw-r--r--mstarddc_spi.c1
-rw-r--r--ni845x_spi.c1
-rw-r--r--parade_lspcon.c1
-rw-r--r--pickit2_spi.c1
-rw-r--r--raiden_debug_spi.c1
-rw-r--r--realtek_mst_i2c_spi.c1
-rw-r--r--sb600spi.c3
-rw-r--r--serprog.c1
-rw-r--r--spi.c9
-rw-r--r--stlinkv3_spi.c1
-rw-r--r--usbblaster_spi.c1
-rw-r--r--wbsio_spi.c1
25 files changed, 5 insertions, 30 deletions
diff --git a/asm106x.c b/asm106x.c
index fe35f94d4..78c0b74cd 100644
--- a/asm106x.c
+++ b/asm106x.c
@@ -123,7 +123,6 @@ static const struct spi_master asm106x_spi_master = {
.max_data_write = MAX_DATA_WRITE_UNLIMITED,
.command = asm106x_command,
.shutdown = asm106x_shutdown,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.probe_opcode = default_spi_probe_opcode,
diff --git a/bitbang_spi.c b/bitbang_spi.c
index 7919e45d7..6488650c1 100644
--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -143,7 +143,6 @@ static const struct spi_master spi_master_bitbang = {
.max_data_read = MAX_DATA_READ_UNLIMITED,
.max_data_write = MAX_DATA_WRITE_UNLIMITED,
.command = bitbang_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = bitbang_spi_shutdown,
diff --git a/buspirate_spi.c b/buspirate_spi.c
index a40fb7087..192d27433 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -178,7 +178,6 @@ static struct spi_master spi_master_buspirate = {
.max_data_read = MAX_DATA_UNSPECIFIED,
.max_data_write = MAX_DATA_UNSPECIFIED,
.command = NULL,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = buspirate_spi_shutdown,
diff --git a/ch341a_spi.c b/ch341a_spi.c
index 75eaf8695..b9be18e5a 100644
--- a/ch341a_spi.c
+++ b/ch341a_spi.c
@@ -413,7 +413,6 @@ static const struct spi_master spi_master_ch341a_spi = {
.max_data_read = 4 * 1024,
.max_data_write = 4 * 1024,
.command = ch341a_spi_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = ch341a_spi_shutdown,
diff --git a/ch347_spi.c b/ch347_spi.c
index c3326b0c0..e828f0089 100644
--- a/ch347_spi.c
+++ b/ch347_spi.c
@@ -253,7 +253,6 @@ static const struct spi_master spi_master_ch347_spi = {
.max_data_read = MAX_DATA_READ_UNLIMITED,
.max_data_write = MAX_DATA_WRITE_UNLIMITED,
.command = ch347_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
diff --git a/dediprog.c b/dediprog.c
index 723f4a80f..60ce6e6e8 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -1034,7 +1034,6 @@ static struct spi_master spi_master_dediprog = {
.max_data_read = 16, /* 18 seems to work fine as well, but 19 times out sometimes with FW 5.15. */
.max_data_write = 16,
.command = dediprog_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = dediprog_spi_read,
.write_256 = dediprog_spi_write_256,
.write_aai = dediprog_spi_write_aai,
diff --git a/digilent_spi.c b/digilent_spi.c
index 55cb6ecd0..5fa60b928 100644
--- a/digilent_spi.c
+++ b/digilent_spi.c
@@ -333,7 +333,6 @@ static const struct spi_master spi_master_digilent_spi = {
.max_data_read = 252,
.max_data_write = 252,
.command = digilent_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = digilent_spi_shutdown,
diff --git a/dirtyjtag_spi.c b/dirtyjtag_spi.c
index 42169ed2a..9f0e43bf6 100644
--- a/dirtyjtag_spi.c
+++ b/dirtyjtag_spi.c
@@ -193,7 +193,6 @@ static const struct spi_master spi_master_dirtyjtag_spi = {
.max_data_read = MAX_DATA_READ_UNLIMITED,
.max_data_write = MAX_DATA_WRITE_UNLIMITED,
.command = dirtyjtag_spi_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
diff --git a/dummyflasher.c b/dummyflasher.c
index 08973327b..a68889b25 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -939,7 +939,6 @@ static const struct spi_master spi_master_dummyflasher = {
.max_data_read = MAX_DATA_READ_UNLIMITED,
.max_data_write = MAX_DATA_UNSPECIFIED,
.command = dummy_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = dummy_spi_write_256,
.shutdown = dummy_shutdown,
diff --git a/it87spi.c b/it87spi.c
index 34dbea088..b2da8751b 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -314,7 +314,6 @@ static const struct spi_master spi_master_it87xx = {
.max_data_read = 3,
.max_data_write = MAX_DATA_UNSPECIFIED,
.command = it8716f_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.map_flash_region = physmap,
.unmap_flash_region = physunmap,
.read = it8716f_spi_chip_read,
diff --git a/jlink_spi.c b/jlink_spi.c
index ad2ca789e..7743c40b6 100644
--- a/jlink_spi.c
+++ b/jlink_spi.c
@@ -184,7 +184,6 @@ static const struct spi_master spi_master_jlink_spi = {
/* Maximum data write size in one go (excluding opcode+address). */
.max_data_write = JTAG_MAX_TRANSFER_SIZE - 5,
.command = jlink_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.features = SPI_MASTER_4BA,
diff --git a/linux_spi.c b/linux_spi.c
index d65b3e890..d849fe4b5 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -116,7 +116,6 @@ static const struct spi_master spi_master_linux = {
.max_data_read = MAX_DATA_UNSPECIFIED, /* TODO? */
.max_data_write = MAX_DATA_UNSPECIFIED, /* TODO? */
.command = linux_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = linux_spi_read,
.write_256 = linux_spi_write_256,
.shutdown = linux_spi_shutdown,
diff --git a/mediatek_i2c_spi.c b/mediatek_i2c_spi.c
index c15df0569..e9c3c8c82 100644
--- a/mediatek_i2c_spi.c
+++ b/mediatek_i2c_spi.c
@@ -456,7 +456,6 @@ static const struct spi_master spi_master_i2c_mediatek = {
// Leave room for 1-byte command and up to a 4-byte address.
.max_data_write = I2C_SMBUS_BLOCK_MAX - 5,
.command = mediatek_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = mediatek_shutdown,
diff --git a/mstarddc_spi.c b/mstarddc_spi.c
index bd652814a..1172cb20b 100644
--- a/mstarddc_spi.c
+++ b/mstarddc_spi.c
@@ -142,7 +142,6 @@ static const struct spi_master spi_master_mstarddc = {
.max_data_read = 256,
.max_data_write = 256,
.command = mstarddc_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = mstarddc_spi_shutdown,
diff --git a/ni845x_spi.c b/ni845x_spi.c
index fd5057dd1..dec6f6f3f 100644
--- a/ni845x_spi.c
+++ b/ni845x_spi.c
@@ -532,7 +532,6 @@ static const struct spi_master spi_programmer_ni845x = {
.max_data_read = MAX_DATA_READ_UNLIMITED,
.max_data_write = MAX_DATA_WRITE_UNLIMITED,
.command = ni845x_spi_transmit,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = ni845x_spi_shutdown,
diff --git a/parade_lspcon.c b/parade_lspcon.c
index a50346e7f..8b9278934 100644
--- a/parade_lspcon.c
+++ b/parade_lspcon.c
@@ -432,7 +432,6 @@ static const struct spi_master spi_master_parade_lspcon = {
.max_data_read = 16,
.max_data_write = 12,
.command = parade_lspcon_send_command,
- .multicommand = default_spi_send_multicommand,
.read = parade_lspcon_read,
.write_256 = parade_lspcon_write_256,
.write_aai = parade_lspcon_write_aai,
diff --git a/pickit2_spi.c b/pickit2_spi.c
index 86c54036c..56894d9a1 100644
--- a/pickit2_spi.c
+++ b/pickit2_spi.c
@@ -380,7 +380,6 @@ static const struct spi_master spi_master_pickit2 = {
.max_data_read = 40,
.max_data_write = 40,
.command = pickit2_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = pickit2_shutdown,
diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c
index d1a09d7ab..5111ae98b 100644
--- a/raiden_debug_spi.c
+++ b/raiden_debug_spi.c
@@ -1320,7 +1320,6 @@ static const struct spi_master spi_master_raiden_debug = {
.max_data_read = 0,
.max_data_write = 0,
.command = NULL,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = raiden_debug_spi_shutdown,
diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c
index 2a5d5ed6a..ee6390c4f 100644
--- a/realtek_mst_i2c_spi.c
+++ b/realtek_mst_i2c_spi.c
@@ -436,7 +436,6 @@ static const struct spi_master spi_master_i2c_realtek_mst = {
.max_data_read = 16,
.max_data_write = 8,
.command = realtek_mst_i2c_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = realtek_mst_i2c_spi_read,
.write_256 = realtek_mst_i2c_spi_write_256,
.write_aai = realtek_mst_i2c_spi_write_aai,
diff --git a/sb600spi.c b/sb600spi.c
index 5b9ac45c4..2e6c2eca7 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -599,7 +599,6 @@ 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,
- .multicommand = default_spi_send_multicommand,
.map_flash_region = physmap,
.unmap_flash_region = physunmap,
.read = default_spi_read,
@@ -612,7 +611,6 @@ 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,
- .multicommand = default_spi_send_multicommand,
.map_flash_region = physmap,
.unmap_flash_region = physunmap,
.read = default_spi_read,
@@ -625,7 +623,6 @@ 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,
- .multicommand = default_spi_send_multicommand,
.map_flash_region = physmap,
.unmap_flash_region = physunmap,
.read = promontory_read_memmapped,
diff --git a/serprog.c b/serprog.c
index 5ddbe3d68..4d93e0757 100644
--- a/serprog.c
+++ b/serprog.c
@@ -461,7 +461,6 @@ static struct spi_master spi_master_serprog = {
.max_data_read = MAX_DATA_READ_UNLIMITED,
.max_data_write = MAX_DATA_WRITE_UNLIMITED,
.command = serprog_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.probe_opcode = default_spi_probe_opcode,
diff --git a/spi.c b/spi.c
index ca27cbb1e..4fe0fa5c9 100644
--- a/spi.c
+++ b/spi.c
@@ -37,7 +37,9 @@ int spi_send_command(const struct flashctx *flash, unsigned int writecnt,
int spi_send_multicommand(const struct flashctx *flash, struct spi_command *cmds)
{
- return flash->mst->spi.multicommand(flash, cmds);
+ if (flash->mst->spi.multicommand)
+ return flash->mst->spi.multicommand(flash, cmds);
+ return default_spi_send_multicommand(flash, cmds);
}
int default_spi_send_command(const struct flashctx *flash, unsigned int writecnt,
@@ -153,10 +155,9 @@ int register_spi_master(const struct spi_master *mst, void *data)
}
}
- if (!mst->write_256 || !mst->read ||
- !mst->multicommand || !mst->probe_opcode ||
+ if (!mst->write_256 || !mst->read || !mst->probe_opcode ||
((mst->command == default_spi_send_command || !mst->command) &&
- (mst->multicommand == default_spi_send_multicommand))) {
+ (mst->multicommand == default_spi_send_multicommand || !mst->multicommand))) {
msg_perr("%s called with incomplete master definition. "
"Please report a bug at flashrom@flashrom.org\n",
__func__);
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c
index 16a66b475..726cdcfdf 100644
--- a/stlinkv3_spi.c
+++ b/stlinkv3_spi.c
@@ -466,7 +466,6 @@ static const struct spi_master spi_programmer_stlinkv3 = {
.max_data_read = UINT16_MAX,
.max_data_write = UINT16_MAX,
.command = stlinkv3_spi_transmit,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = stlinkv3_spi_shutdown,
diff --git a/usbblaster_spi.c b/usbblaster_spi.c
index 75d5be732..958d4ea54 100644
--- a/usbblaster_spi.c
+++ b/usbblaster_spi.c
@@ -168,7 +168,6 @@ static const struct spi_master spi_master_usbblaster = {
.max_data_read = 256,
.max_data_write = 256,
.command = usbblaster_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
.shutdown = usbblaster_shutdown,
diff --git a/wbsio_spi.c b/wbsio_spi.c
index d635a09ea..ee79ef2a8 100644
--- a/wbsio_spi.c
+++ b/wbsio_spi.c
@@ -186,7 +186,6 @@ static const struct spi_master spi_master_wbsio = {
.max_data_read = MAX_DATA_UNSPECIFIED,
.max_data_write = MAX_DATA_UNSPECIFIED,
.command = wbsio_spi_send_command,
- .multicommand = default_spi_send_multicommand,
.map_flash_region = physmap,
.unmap_flash_region = physunmap,
.read = wbsio_spi_read,