diff options
author | Aaron Durbin <adurbin@chromium.org> | 2020-01-11 14:03:27 -0700 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2020-01-16 15:21:08 +0000 |
commit | f584f19efc58ba3c80a462024ae680320b17b9ce (patch) | |
tree | 69b4419e008e40d2442d11e28af48b28cc535472 /src/drivers/spi/spi_flash.c | |
parent | cb01aa586f45277043d36500d9694d750ed33190 (diff) | |
download | coreboot-f584f19efc58ba3c80a462024ae680320b17b9ce.tar.xz |
drivers/spi/spi_flash: separate out protection ops
Put the write protection into its own object. This allows
for easier future reuse of objects in future consolidation
patches. It's also possible to eliminate the code implmementing
these in the future if the platform doesn't require it. For now
leave current behavior as-is.
The names of the callbacks were shortened as they are now in
the spi_flash_protection_ops object which is a new field in the
spi_flash object.
Change-Id: I2fec4e4430709fcf3e08a55dd36583211c035c08
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38376
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.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 8f3a829e15..312f2f0817 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -520,13 +520,13 @@ int spi_flash_is_write_protected(const struct spi_flash *flash, if (!region_is_subregion(&flash_region, region)) return -1; - if (!flash->ops->get_write_protection) { + if (!flash->prot_ops) { printk(BIOS_WARNING, "SPI: Write-protection gathering not " "implemented for this vendor.\n"); return -1; } - return flash->ops->get_write_protection(flash, region); + return flash->prot_ops->get_write(flash, region); } int spi_flash_set_write_protected(const struct spi_flash *flash, @@ -545,14 +545,13 @@ int spi_flash_set_write_protected(const struct spi_flash *flash, if (!region_is_subregion(&flash_region, region)) return -1; - if (!flash->ops->set_write_protection) { + if (!flash->prot_ops) { printk(BIOS_WARNING, "SPI: Setting write-protection is not " "implemented for this vendor.\n"); return -1; } - ret = flash->ops->set_write_protection(flash, region, non_volatile, - mode); + ret = flash->prot_ops->set_write(flash, region, non_volatile, mode); if (ret == 0 && mode != SPI_WRITE_PROTECTION_PRESERVE) { printk(BIOS_INFO, "SPI: SREG lock-down was set to "); |