diff options
author | Furquan Shaikh <furquan@chromium.org> | 2017-05-17 17:26:01 -0700 |
---|---|---|
committer | Furquan Shaikh <furquan@google.com> | 2017-05-19 21:23:39 +0200 |
commit | e2fc5e25f2d1cab86edac352d1a91f55c15c9f0a (patch) | |
tree | 71a86a3dd19e445a04d9088eedd1f14373da75bb /src/drivers/spi/gigadevice.c | |
parent | a1491574ef2c91ff8b89df70feba67ad34836c75 (diff) | |
download | coreboot-e2fc5e25f2d1cab86edac352d1a91f55c15c9f0a.tar.xz |
drivers/spi/spi_flash: Move flash ops to spi_flash_ops structure
Define a new spi_flash_ops structure, move all spi flash operations to
this structure and add a pointer to this structure in struct spi_flash.
BUG=b:38330715
Change-Id: I550cc4556fc4b63ebc174a7e2fde42251fe56052
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://review.coreboot.org/19757
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/drivers/spi/gigadevice.c')
-rw-r--r-- | src/drivers/spi/gigadevice.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c index f68be8b017..becc215e76 100644 --- a/src/drivers/spi/gigadevice.c +++ b/src/drivers/spi/gigadevice.c @@ -170,6 +170,17 @@ out: return ret; } +static const struct spi_flash_ops spi_flash_ops = { + .write = gigadevice_write, + .erase = spi_flash_cmd_erase, + .status = spi_flash_cmd_status, +#if IS_ENABLED(CONFIG_SPI_FLASH_NO_FAST_READ) + .read = spi_flash_cmd_read_slow, +#else + .read = spi_flash_cmd_read_fast, +#endif +}; + int spi_flash_probe_gigadevice(const struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) { @@ -200,14 +211,7 @@ int spi_flash_probe_gigadevice(const struct spi_slave *spi, u8 *idcode, flash->erase_cmd = CMD_GD25_SE; flash->status_cmd = CMD_GD25_RDSR; - flash->internal_write = gigadevice_write; - flash->internal_erase = spi_flash_cmd_erase; - flash->internal_status = spi_flash_cmd_status; -#if CONFIG_SPI_FLASH_NO_FAST_READ - flash->internal_read = spi_flash_cmd_read_slow; -#else - flash->internal_read = spi_flash_cmd_read_fast; -#endif + flash->ops = &spi_flash_ops; return 0; } |