summaryrefslogtreecommitdiff
path: root/common/spi_flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/spi_flash.c')
-rw-r--r--common/spi_flash.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/common/spi_flash.c b/common/spi_flash.c
index 3f003052bf..c4346ef48b 100644
--- a/common/spi_flash.c
+++ b/common/spi_flash.c
@@ -153,7 +153,7 @@ int spi_flash_read(uint8_t *buf_usr, unsigned int offset, unsigned int bytes)
{
int i, read_size, ret, spi_addr;
uint8_t cmd[4];
- if (offset + bytes > CONFIG_FLASH_SIZE)
+ if (offset + bytes > CONFIG_FLASH_SIZE_BYTES)
return EC_ERROR_INVAL;
cmd[0] = SPI_FLASH_READ;
for (i = 0; i < bytes; i += read_size) {
@@ -227,7 +227,7 @@ int spi_flash_erase(unsigned int offset, unsigned int bytes)
int rv = EC_SUCCESS;
/* Invalid input */
- if (offset + bytes > CONFIG_FLASH_SIZE)
+ if (offset + bytes > CONFIG_FLASH_SIZE_BYTES)
return EC_ERROR_INVAL;
/* Not aligned to sector (4kb) */
@@ -280,7 +280,7 @@ int spi_flash_write(unsigned int offset, unsigned int bytes,
int rv, write_size;
/* Invalid input */
- if (!data || offset + bytes > CONFIG_FLASH_SIZE ||
+ if (!data || offset + bytes > CONFIG_FLASH_SIZE_BYTES ||
bytes > SPI_FLASH_MAX_WRITE_SIZE)
return EC_ERROR_INVAL;
@@ -435,7 +435,8 @@ int spi_flash_check_protect(unsigned int offset, unsigned int bytes)
int rv = EC_SUCCESS;
/* Invalid value */
- if (sr1 == 0xff || sr2 == 0xff || offset + bytes > CONFIG_FLASH_SIZE)
+ if (sr1 == 0xff || sr2 == 0xff ||
+ offset + bytes > CONFIG_FLASH_SIZE_BYTES)
return EC_ERROR_INVAL;
/* Compute current protect range */
@@ -466,7 +467,8 @@ int spi_flash_set_protect(unsigned int offset, unsigned int bytes)
uint8_t sr2 = spi_flash_get_status2();
/* Invalid values */
- if (sr1 == 0xff || sr2 == 0xff || offset + bytes > CONFIG_FLASH_SIZE)
+ if (sr1 == 0xff || sr2 == 0xff ||
+ offset + bytes > CONFIG_FLASH_SIZE_BYTES)
return EC_ERROR_INVAL;
/* Compute desired protect range */
@@ -608,7 +610,7 @@ static int command_spi_flashread(int argc, char **argv)
spi_enable(CONFIG_SPI_FLASH_PORT, 1);
/* Can't read past size of memory */
- if (offset + bytes > CONFIG_FLASH_SIZE)
+ if (offset + bytes > CONFIG_FLASH_SIZE_BYTES)
return EC_ERROR_INVAL;
/* Wait for previous operation to complete */