Thomas Heijligen has submitted this change. ( https://review.coreboot.org/c/flashrom/+/67481 )
Change subject: spi: Make 'default_spi_send_multicommand' the default unless defined ......................................................................
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 --- M asm106x.c M bitbang_spi.c M buspirate_spi.c M ch341a_spi.c M ch347_spi.c M dediprog.c M digilent_spi.c M dirtyjtag_spi.c M dummyflasher.c M it87spi.c M jlink_spi.c M linux_spi.c M mediatek_i2c_spi.c M mstarddc_spi.c M ni845x_spi.c M parade_lspcon.c M pickit2_spi.c M raiden_debug_spi.c M realtek_mst_i2c_spi.c M sb600spi.c M serprog.c M spi.c M stlinkv3_spi.c M usbblaster_spi.c M wbsio_spi.c 25 files changed, 29 insertions(+), 30 deletions(-)
Approvals: build bot (Jenkins): Verified Thomas Heijligen: Looks good to me, approved
diff --git a/asm106x.c b/asm106x.c index fe35f94..78c0b74 100644 --- a/asm106x.c +++ b/asm106x.c @@ -123,7 +123,6 @@ .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 7919e45..6488650 100644 --- a/bitbang_spi.c +++ b/bitbang_spi.c @@ -143,7 +143,6 @@ .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 a40fb70..192d274 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -178,7 +178,6 @@ .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 75eaf86..b9be18e 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -413,7 +413,6 @@ .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 c3326b0..e828f00 100644 --- a/ch347_spi.c +++ b/ch347_spi.c @@ -253,7 +253,6 @@ .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 723f4a8..60ce6e6 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1034,7 +1034,6 @@ .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 55cb6ec..5fa60b9 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -333,7 +333,6 @@ .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 42169ed..9f0e43b 100644 --- a/dirtyjtag_spi.c +++ b/dirtyjtag_spi.c @@ -193,7 +193,6 @@ .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 0897332..a68889b 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -939,7 +939,6 @@ .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 34dbea0..b2da875 100644 --- a/it87spi.c +++ b/it87spi.c @@ -314,7 +314,6 @@ .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 ad2ca78..7743c40 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -184,7 +184,6 @@ /* 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 d65b3e8..d849fe4 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -116,7 +116,6 @@ .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 c15df05..e9c3c8c 100644 --- a/mediatek_i2c_spi.c +++ b/mediatek_i2c_spi.c @@ -456,7 +456,6 @@ // 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 bd65281..1172cb2 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -142,7 +142,6 @@ .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 fd5057d..dec6f6f 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -532,7 +532,6 @@ .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 a50346e..8b92789 100644 --- a/parade_lspcon.c +++ b/parade_lspcon.c @@ -432,7 +432,6 @@ .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 86c5403..56894d9 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -380,7 +380,6 @@ .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 d1a09d7..5111ae9 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1320,7 +1320,6 @@ .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 2a5d5ed..ee6390c 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -436,7 +436,6 @@ .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 5b9ac45..2e6c2ec 100644 --- a/sb600spi.c +++ b/sb600spi.c @@ -599,7 +599,6 @@ .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 @@ .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 @@ .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 5ddbe3d..4d93e07 100644 --- a/serprog.c +++ b/serprog.c @@ -461,7 +461,6 @@ .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 ca27cbb..4fe0fa5 100644 --- a/spi.c +++ b/spi.c @@ -37,7 +37,9 @@
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 @@ } }
- 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 16a66b4..726cdcf 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -466,7 +466,6 @@ .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 75d5be7..958d4ea 100644 --- a/usbblaster_spi.c +++ b/usbblaster_spi.c @@ -168,7 +168,6 @@ .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 d635a09..ee79ef2 100644 --- a/wbsio_spi.c +++ b/wbsio_spi.c @@ -186,7 +186,6 @@ .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,