summaryrefslogtreecommitdiffstats
path: root/spi.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-09-09 23:10:24 +1000
committerThomas Heijligen <src@posteo.de>2023-02-27 10:27:55 +0000
commitfc533e25623af76d0e6ff87681a7c3122df1607e (patch)
tree2ca2e0e5357a75691722a23bc0ef48c027735138 /spi.c
parent648dc4a6535a699ebd7abd9d84cced64ff56d90d (diff)
downloadflashrom-fc533e25623af76d0e6ff87681a7c3122df1607e.tar.gz
flashrom-fc533e25623af76d0e6ff87681a7c3122df1607e.tar.bz2
flashrom-fc533e25623af76d0e6ff87681a7c3122df1607e.zip
spi: Make 'default_spi_send_command' the default unless defined
A NULL func pointer is necessary and sufficient for the condition `NULL func pointer => default_spi_send_command' as to not need this explicit specification of 'default'. Therefore drop the explicit need to specify the 'default_spi_send_command' 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: I63abcb8c64f233cdbf58a149a31051fa648305a2 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/67480 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
Diffstat (limited to 'spi.c')
-rw-r--r--spi.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/spi.c b/spi.c
index 6c2c4c437..ca27cbb1e 100644
--- a/spi.c
+++ b/spi.c
@@ -30,8 +30,9 @@ int spi_send_command(const struct flashctx *flash, unsigned int writecnt,
unsigned int readcnt, const unsigned char *writearr,
unsigned char *readarr)
{
- return flash->mst->spi.command(flash, writecnt, readcnt, writearr,
- readarr);
+ if (flash->mst->spi.command)
+ return flash->mst->spi.command(flash, writecnt, readcnt, writearr, readarr);
+ return default_spi_send_command(flash, writecnt, readcnt, writearr, readarr);
}
int spi_send_multicommand(const struct flashctx *flash, struct spi_command *cmds)
@@ -152,9 +153,9 @@ int register_spi_master(const struct spi_master *mst, void *data)
}
}
- if (!mst->write_256 || !mst->read || !mst->command ||
+ if (!mst->write_256 || !mst->read ||
!mst->multicommand || !mst->probe_opcode ||
- ((mst->command == default_spi_send_command) &&
+ ((mst->command == default_spi_send_command || !mst->command) &&
(mst->multicommand == default_spi_send_multicommand))) {
msg_perr("%s called with incomplete master definition. "
"Please report a bug at flashrom@flashrom.org\n",