diff options
author | Edward O'Callaghan <quasisec@google.com> | 2022-09-09 23:01:05 +1000 |
---|---|---|
committer | Felix Singer <felixsinger@posteo.net> | 2022-12-21 04:44:47 +0000 |
commit | 972c1550b4d67abdfe187100905f95030e18a796 (patch) | |
tree | b1ac9658d47757a48275e6251f48008012c77873 | |
parent | 8b0250b32b89a54df16989369c0cb8330d86cb77 (diff) | |
download | flashrom-972c1550b4d67abdfe187100905f95030e18a796.tar.gz flashrom-972c1550b4d67abdfe187100905f95030e18a796.tar.bz2 flashrom-972c1550b4d67abdfe187100905f95030e18a796.zip |
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 <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67479
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
-rw-r--r-- | bitbang_spi.c | 1 | ||||
-rw-r--r-- | buspirate_spi.c | 1 | ||||
-rw-r--r-- | ch341a_spi.c | 1 | ||||
-rw-r--r-- | digilent_spi.c | 1 | ||||
-rw-r--r-- | dummyflasher.c | 1 | ||||
-rw-r--r-- | ft2232_spi.c | 1 | ||||
-rw-r--r-- | ichspi.c | 3 | ||||
-rw-r--r-- | jlink_spi.c | 1 | ||||
-rw-r--r-- | linux_spi.c | 1 | ||||
-rw-r--r-- | mediatek_i2c_spi.c | 1 | ||||
-rw-r--r-- | mstarddc_spi.c | 1 | ||||
-rw-r--r-- | ni845x_spi.c | 1 | ||||
-rw-r--r-- | pickit2_spi.c | 1 | ||||
-rw-r--r-- | raiden_debug_spi.c | 1 | ||||
-rw-r--r-- | sb600spi.c | 3 | ||||
-rw-r--r-- | serprog.c | 1 | ||||
-rw-r--r-- | spi.c | 6 | ||||
-rw-r--r-- | stlinkv3_spi.c | 1 | ||||
-rw-r--r-- | usbblaster_spi.c | 1 |
19 files changed, 4 insertions, 24 deletions
diff --git a/bitbang_spi.c b/bitbang_spi.c index fadca70a1..7919e45d7 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 dbaac4e5e..a40fb7087 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 fe18d137f..75eaf8695 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 6575cbffd..55cb6ecd0 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 e5a9c12b3..1960e92ef 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 aec21bc9d..dfec1a0a5 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, }; @@ -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 63d15b8f8..ad2ca789e 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 ee023045c..d65b3e890 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 3aa9dd97b..c15df0569 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 0c11717bb..bd652814a 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 2750334b9..fd5057dd1 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 e8c80af9d..86c54036c 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 8260abd07..d1a09d7ab 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 8c018a3dc..5b9ac45c4 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, }; @@ -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, }; @@ -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 1d5763b49..16a66b475 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 5e2c020a3..75d5be732 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, }; |