Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/67480 )
Change subject: spi: Make 'default_spi_send_command' the default unless defined ......................................................................
spi: Make 'default_spi_send_command' the default unless defined
Drop the explicit need to specify the default 'default_spi_send_command' callback function pointer.
This simplifies the code and driver development.
Change-Id: I63abcb8c64f233cdbf58a149a31051fa648305a2 Signed-off-by: Edward O'Callaghan quasisec@google.com --- M ft2232_spi.c M spi.c 2 files changed, 20 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/80/67480/1
diff --git a/ft2232_spi.c b/ft2232_spi.c index ab9d296..1942fb4 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -295,7 +295,6 @@ .features = SPI_MASTER_4BA, .max_data_read = 64 * 1024, .max_data_write = 256, - .command = default_spi_send_command, .multicommand = ft2232_spi_send_multicommand, .read = default_spi_read, .write_256 = default_spi_write_256, diff --git a/spi.c b/spi.c index 25df687..9d768a4 100644 --- a/spi.c +++ b/spi.c @@ -30,8 +30,9 @@ 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 @@ } }
- 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",