aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/spi/spi_flash.c
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-05-17 17:26:01 -0700
committerFurquan Shaikh <furquan@google.com>2017-05-19 21:23:39 +0200
commite2fc5e25f2d1cab86edac352d1a91f55c15c9f0a (patch)
tree71a86a3dd19e445a04d9088eedd1f14373da75bb /src/drivers/spi/spi_flash.c
parenta1491574ef2c91ff8b89df70feba67ad34836c75 (diff)
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/spi_flash.c')
-rw-r--r--src/drivers/spi/spi_flash.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 564d573a83..c145379e1a 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -350,7 +350,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)
{
- return flash->internal_read(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,
@@ -361,7 +361,7 @@ int spi_flash_write(const struct spi_flash *flash, u32 offset, size_t len,
if (spi_flash_volatile_group_begin(flash))
return -1;
- ret = flash->internal_write(flash, offset, len, buf);
+ ret = flash->ops->write(flash, offset, len, buf);
if (spi_flash_volatile_group_end(flash))
return -1;
@@ -376,7 +376,7 @@ int spi_flash_erase(const struct spi_flash *flash, u32 offset, size_t len)
if (spi_flash_volatile_group_begin(flash))
return -1;
- ret = flash->internal_erase(flash, offset, len);
+ ret = flash->ops->erase(flash, offset, len);
if (spi_flash_volatile_group_end(flash))
return -1;
@@ -386,7 +386,10 @@ int spi_flash_erase(const struct spi_flash *flash, u32 offset, size_t len)
int spi_flash_status(const struct spi_flash *flash, u8 *reg)
{
- return flash->internal_status(flash, reg);
+ if (flash->ops->status)
+ return flash->ops->status(flash, reg);
+
+ return -1;
}
static uint32_t volatile_group_count CAR_GLOBAL;