lib/cbfs_spi: provide boot_device_rw() support
Provide the RW boot device operations for the common cbfs SPI wrapper. The RW region_device is the same as the read-only one. As noted in the boot_device_rw() introduction patch the mmap() support should not be used in conjuction with writing as that results in incoherent operations. That's fine as the current mmap() support is only used in the cbfs layer which does not support writing, i.e. no cbfs regions would be written to with any previous or outstanding mmap() calls. BUG=chrome-os-partner:56151 Change-Id: I7cc7309a68ad23b30208ac961b1999a79626b307 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/16199 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
parent
dcbccd6a1e
commit
504b8f2da2
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue