summaryrefslogtreecommitdiff
path: root/src/drivers/spi
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/spi')
-rw-r--r--src/drivers/spi/spi_flash.c12
-rw-r--r--src/drivers/spi/winbond.c7
2 files changed, 9 insertions, 10 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 42952df531..11597c6c1d 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -610,12 +610,12 @@ int spi_flash_status(const struct spi_flash *flash, u8 *reg)
int spi_flash_is_write_protected(const struct spi_flash *flash,
const struct region *region)
{
- struct region flash_region = { 0 };
+ struct region flash_region;
if (!flash || !region)
return -1;
- flash_region.size = flash->size;
+ flash_region = region_create(0, flash->size);
if (!region_is_subregion(&flash_region, region))
return -1;
@@ -633,13 +633,13 @@ int spi_flash_set_write_protected(const struct spi_flash *flash,
const struct region *region,
const enum spi_flash_status_reg_lockdown mode)
{
- struct region flash_region = { 0 };
+ struct region flash_region;
int ret;
if (!flash)
return -1;
- flash_region.size = flash->size;
+ flash_region = region_create(0, flash->size);
if (!region_is_subregion(&flash_region, region))
return -1;
@@ -755,12 +755,12 @@ int spi_flash_ctrlr_protect_region(const struct spi_flash *flash,
const enum ctrlr_prot_type type)
{
const struct spi_ctrlr *ctrlr;
- struct region flash_region = { 0 };
+ struct region flash_region;
if (!flash)
return -1;
- flash_region.size = flash->size;
+ flash_region = region_create(0, flash->size);
if (!region_is_subregion(&flash_region, region))
return -1;
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c
index 3137bfe8a7..3426d08e70 100644
--- a/src/drivers/spi/winbond.c
+++ b/src/drivers/spi/winbond.c
@@ -267,8 +267,7 @@ static void winbond_bpbits_to_region(const size_t granularity,
tb = !tb;
}
- out->offset = tb ? 0 : flash_size - protected_size;
- out->size = protected_size;
+ *out = region_create(tb ? 0 : flash_size - protected_size, protected_size);
}
/*
@@ -525,8 +524,8 @@ winbond_set_write_protection(const struct spi_flash *flash,
if (region_sz(&wp_region) > flash->size / 2) {
cmp = 1;
- wp_region.offset = tb ? 0 : region_sz(&wp_region);
- wp_region.size = flash->size - region_sz(&wp_region);
+ wp_region = region_create(tb ? 0 : region_sz(&wp_region),
+ flash->size - region_sz(&wp_region));
tb = !tb;
} else {
cmp = 0;