summaryrefslogtreecommitdiff
path: root/src/drivers/spi/spi_flash.c
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2020-01-11 11:44:47 -0700
committerAaron Durbin <adurbin@chromium.org>2020-01-16 15:20:49 +0000
commitcb01aa586f45277043d36500d9694d750ed33190 (patch)
treef7dcf8fad5f2f747131fdb66ba734336e84f5ad2 /src/drivers/spi/spi_flash.c
parent56258ff92bcd0e930c62b6ae47567ed9b3b7efaf (diff)
downloadcoreboot-cb01aa586f45277043d36500d9694d750ed33190.tar.xz
drivers/spi/spi_flash: assume spi_flash read callback exists
spi_flash_erase() and spi_flash_write() already assume their respective callbacks are supplied in the spi_flash_ops object. Make the same assumption in spi_flash_read(). In order to do this the spi_flash_ops objects from the drivers need to reference the the previously used fallback read command, spi_flash_read_chunked(). This function is made global and renamed to spi_flash_cmd_read() for consistency. By doing this further dead code elimination can be achieved when the spi flash drivers aren't included in the build. A Hatch Chrome OS build achieves a further text segment reduction of 0.5KiB in verstage, romstage, and ramstage. Change-Id: I7fee55e6ffc1983657c3adde025a0e8c9d12ca23 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38366 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/drivers/spi/spi_flash.c')
-rw-r--r--src/drivers/spi/spi_flash.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 4a86146503..8f3a829e15 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -127,7 +127,7 @@ int spi_flash_cmd_write(const struct spi_slave *spi, const u8 *cmd,
/* Perform the read operation honoring spi controller fifo size, reissuing
* the read command until the full request completed. */
-static int spi_flash_read_chunked(const struct spi_flash *flash, u32 offset,
+int spi_flash_cmd_read(const struct spi_flash *flash, u32 offset,
size_t len, void *buf)
{
u8 cmd[5];
@@ -465,10 +465,7 @@ int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash)
int spi_flash_read(const struct spi_flash *flash, u32 offset, size_t len,
void *buf)
{
- if (flash->ops->read)
- return flash->ops->read(flash, offset, len, buf);
-
- return spi_flash_read_chunked(flash, offset, len, buf);
+ return flash->ops->read(flash, offset, len, buf);
}
int spi_flash_write(const struct spi_flash *flash, u32 offset, size_t len,