1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

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>
This commit is contained in:
Edward O'Callaghan 2022-09-09 23:01:05 +10:00 committed by Felix Singer
parent 8b0250b32b
commit 972c1550b4
19 changed files with 4 additions and 24 deletions

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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,
};

6
spi.c
View File

@ -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))) {

View File

@ -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,
};

View File

@ -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,
};