summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drivers/spi/cbfs_spi.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/drivers/spi/cbfs_spi.c b/src/drivers/spi/cbfs_spi.c
index bbe9125dd5..1895b9df1e 100644
--- a/src/drivers/spi/cbfs_spi.c
+++ b/src/drivers/spi/cbfs_spi.c
@@ -34,10 +34,29 @@ static ssize_t spi_readat(const struct region_device *rd, void *b,
return size;
}
+static ssize_t spi_writeat(const struct region_device *rd, const void *b,
+ size_t offset, size_t size)
+{
+ if (spi_flash_info->write(spi_flash_info, offset, size, b))
+ return -1;
+ return size;
+}
+
+static ssize_t spi_eraseat(const struct region_device *rd,
+ size_t offset, size_t size)
+{
+ if (spi_flash_info->erase(spi_flash_info, offset, size))
+ return -1;
+ return size;
+}
+
+/* Provide all operations on the same device. */
static const struct region_device_ops spi_ops = {
.mmap = mmap_helper_rdev_mmap,
.munmap = mmap_helper_rdev_munmap,
.readat = spi_readat,
+ .writeat = spi_writeat,
+ .eraseat = spi_eraseat,
};
static struct mmap_helper_region_device mdev =
@@ -78,3 +97,9 @@ const struct region_device *boot_device_ro(void)
return &mdev.rdev;
}
+
+/* The read-only and read-write implementations are symmetric. */
+const struct region_device *boot_device_rw(void)
+{
+ return boot_device_ro();
+}