From 972c1550b4d67abdfe187100905f95030e18a796 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Fri, 9 Sep 2022 23:01:05 +1000 Subject: spi: Make 'default_spi_write_aai' the default unless defined A NULL func pointer is necessary and sufficient for the condition `NULL func pointer => default_spi_write_aai' as to not need this explicit specification of 'default'. Therefore Drop the explicit need to specify the 'default_spi_write_aai' 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: I7f14aaea0edcf0c08cea0e9cd27d58152707fb2a Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/67479 Reviewed-by: Peter Marheine Reviewed-by: Anastasia Klimchuk Tested-by: build bot (Jenkins) Reviewed-by: Felix Singer --- bitbang_spi.c | 1 - buspirate_spi.c | 1 - ch341a_spi.c | 1 - digilent_spi.c | 1 - dummyflasher.c | 1 - ft2232_spi.c | 1 - ichspi.c | 3 --- jlink_spi.c | 1 - linux_spi.c | 1 - mediatek_i2c_spi.c | 1 - mstarddc_spi.c | 1 - ni845x_spi.c | 1 - pickit2_spi.c | 1 - raiden_debug_spi.c | 1 - sb600spi.c | 3 --- serprog.c | 1 - spi.c | 6 ++++-- stlinkv3_spi.c | 1 - usbblaster_spi.c | 1 - 19 files changed, 4 insertions(+), 24 deletions(-) diff --git a/bitbang_spi.c b/bitbang_spi.c index fadca70a..7919e45d 100644 --- a/bitbang_spi.c +++ b/bitbang_spi.c @@ -146,7 +146,6 @@ static const struct spi_master spi_master_bitbang = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = bitbang_spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/buspirate_spi.c b/buspirate_spi.c index dbaac4e5..a40fb708 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -181,7 +181,6 @@ static struct spi_master spi_master_buspirate = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = buspirate_spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/ch341a_spi.c b/ch341a_spi.c index fe18d137..75eaf869 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -416,7 +416,6 @@ static const struct spi_master spi_master_ch341a_spi = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = ch341a_spi_shutdown, .probe_opcode = default_spi_probe_opcode, .delay = ch341a_spi_delay, diff --git a/digilent_spi.c b/digilent_spi.c index 6575cbff..55cb6ecd 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -336,7 +336,6 @@ static const struct spi_master spi_master_digilent_spi = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = digilent_spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/dummyflasher.c b/dummyflasher.c index e5a9c12b..1960e92e 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -929,7 +929,6 @@ static const struct spi_master spi_master_dummyflasher = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = dummy_spi_write_256, - .write_aai = default_spi_write_aai, .probe_opcode = dummy_spi_probe_opcode, }; diff --git a/ft2232_spi.c b/ft2232_spi.c index aec21bc9..dfec1a0a 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -299,7 +299,6 @@ static const struct spi_master spi_master_ft2232 = { .multicommand = ft2232_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = ft2232_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/ichspi.c b/ichspi.c index 7b23b423..1522d2b4 100644 --- a/ichspi.c +++ b/ichspi.c @@ -1947,7 +1947,6 @@ static const struct spi_master spi_master_ich7 = { .unmap_flash_region = physunmap, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, }; static const struct spi_master spi_master_ich9 = { @@ -1959,7 +1958,6 @@ static const struct spi_master spi_master_ich9 = { .unmap_flash_region = physunmap, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .probe_opcode = ich_spi_probe_opcode, }; @@ -2383,7 +2381,6 @@ static const struct spi_master spi_master_via = { .unmap_flash_region = physunmap, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .probe_opcode = ich_spi_probe_opcode, }; diff --git a/jlink_spi.c b/jlink_spi.c index 63d15b8f..ad2ca789 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -187,7 +187,6 @@ static const struct spi_master spi_master_jlink_spi = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .features = SPI_MASTER_4BA, .shutdown = jlink_spi_shutdown, .probe_opcode = default_spi_probe_opcode, diff --git a/linux_spi.c b/linux_spi.c index ee023045..d65b3e89 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -119,7 +119,6 @@ static const struct spi_master spi_master_linux = { .multicommand = default_spi_send_multicommand, .read = linux_spi_read, .write_256 = linux_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = linux_spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/mediatek_i2c_spi.c b/mediatek_i2c_spi.c index 3aa9dd97..c15df056 100644 --- a/mediatek_i2c_spi.c +++ b/mediatek_i2c_spi.c @@ -459,7 +459,6 @@ static const struct spi_master spi_master_i2c_mediatek = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = mediatek_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/mstarddc_spi.c b/mstarddc_spi.c index 0c11717b..bd652814 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -145,7 +145,6 @@ static const struct spi_master spi_master_mstarddc = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = mstarddc_spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/ni845x_spi.c b/ni845x_spi.c index 2750334b..fd5057dd 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -535,7 +535,6 @@ static const struct spi_master spi_programmer_ni845x = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = ni845x_spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/pickit2_spi.c b/pickit2_spi.c index e8c80af9..86c54036 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -383,7 +383,6 @@ static const struct spi_master spi_master_pickit2 = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = pickit2_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index 8260abd0..d1a09d7a 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1323,7 +1323,6 @@ static const struct spi_master spi_master_raiden_debug = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = raiden_debug_spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/sb600spi.c b/sb600spi.c index 8c018a3d..5b9ac45c 100644 --- a/sb600spi.c +++ b/sb600spi.c @@ -604,7 +604,6 @@ static const struct spi_master spi_master_sb600 = { .unmap_flash_region = physunmap, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = sb600spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; @@ -618,7 +617,6 @@ static const struct spi_master spi_master_yangtze = { .unmap_flash_region = physunmap, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = sb600spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; @@ -632,7 +630,6 @@ static const struct spi_master spi_master_promontory = { .unmap_flash_region = physunmap, .read = promontory_read_memmapped, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = sb600spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/serprog.c b/serprog.c index 84dfd238..4e131e51 100644 --- a/serprog.c +++ b/serprog.c @@ -464,7 +464,6 @@ static struct spi_master spi_master_serprog = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .probe_opcode = default_spi_probe_opcode, .delay = serprog_delay, }; diff --git a/spi.c b/spi.c index e708ba9c..6c2c4c43 100644 --- a/spi.c +++ b/spi.c @@ -131,7 +131,9 @@ int spi_chip_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { - return flash->mst->spi.write_aai(flash, buf, start, len); + if (flash->mst->spi.write_aai) + return flash->mst->spi.write_aai(flash, buf, start, len); + return default_spi_write_aai(flash, buf, start, len); } bool default_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode) @@ -150,7 +152,7 @@ int register_spi_master(const struct spi_master *mst, void *data) } } - if (!mst->write_aai || !mst->write_256 || !mst->read || !mst->command || + if (!mst->write_256 || !mst->read || !mst->command || !mst->multicommand || !mst->probe_opcode || ((mst->command == default_spi_send_command) && (mst->multicommand == default_spi_send_multicommand))) { diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 1d5763b4..16a66b47 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -469,7 +469,6 @@ static const struct spi_master spi_programmer_stlinkv3 = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = stlinkv3_spi_shutdown, .probe_opcode = default_spi_probe_opcode, }; diff --git a/usbblaster_spi.c b/usbblaster_spi.c index 5e2c020a..75d5be73 100644 --- a/usbblaster_spi.c +++ b/usbblaster_spi.c @@ -171,7 +171,6 @@ static const struct spi_master spi_master_usbblaster = { .multicommand = default_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, - .write_aai = default_spi_write_aai, .shutdown = usbblaster_shutdown, .probe_opcode = default_spi_probe_opcode, }; -- cgit v1.2.3