summaryrefslogtreecommitdiff
path: root/common/spi_flash.c
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2018-08-01 13:52:28 +0200
committerchrome-bot <chrome-bot@chromium.org>2018-08-01 19:35:13 -0700
commit120dc54711a07d6f8e6b597af2bcd04ede3872ae (patch)
tree917b0a4ecbde6c1cef6a2723a24dfbbd8cf30ef9 /common/spi_flash.c
parentf8366e0da0c05f96c33f6373ee5745b4201a58fe (diff)
downloadchrome-ec-120dc54711a07d6f8e6b597af2bcd04ede3872ae.tar.gz
common/spi_flash: don't mix up unsigned and signed types
Change-Id: Ib06fd16ddbe6455b0f194ee4b6c6f1c1bc8f3adc Signed-off-by: Patrick Georgi <pgeorgi@google.com> Found-by: Coverity Scan #142081, #142083 Reviewed-on: https://chromium-review.googlesource.com/1158505 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'common/spi_flash.c')
-rw-r--r--common/spi_flash.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/common/spi_flash.c b/common/spi_flash.c
index 70e3d89c49..d8e4afef28 100644
--- a/common/spi_flash.c
+++ b/common/spi_flash.c
@@ -65,7 +65,7 @@ static int spi_flash_write_enable(void)
/**
* Returns the contents of SPI flash status register 1
- * @return register contents or -1 on error
+ * @return register contents or 0xff on error
*/
uint8_t spi_flash_get_status1(void)
{
@@ -73,14 +73,14 @@ uint8_t spi_flash_get_status1(void)
uint8_t resp;
if (spi_transaction(SPI_FLASH_DEVICE, &cmd, 1, &resp, 1) != EC_SUCCESS)
- return -1;
+ return 0xff;
return resp;
}
/**
* Returns the contents of SPI flash status register 2
- * @return register contents or -1 on error
+ * @return register contents or 0xff on error
*/
uint8_t spi_flash_get_status2(void)
{
@@ -93,7 +93,7 @@ uint8_t spi_flash_get_status2(void)
#endif
if (spi_transaction(SPI_FLASH_DEVICE, &cmd, 1, &resp, 1) != EC_SUCCESS)
- return -1;
+ return 0xff;
return resp;
}
@@ -435,7 +435,7 @@ int spi_flash_check_protect(unsigned int offset, unsigned int bytes)
int rv = EC_SUCCESS;
/* Invalid value */
- if (sr1 == -1 || sr2 == -1 || offset + bytes > CONFIG_FLASH_SIZE)
+ if (sr1 == 0xff || sr2 == 0xff || offset + bytes > CONFIG_FLASH_SIZE)
return EC_ERROR_INVAL;
/* Compute current protect range */
@@ -466,7 +466,7 @@ int spi_flash_set_protect(unsigned int offset, unsigned int bytes)
uint8_t sr2 = spi_flash_get_status2();
/* Invalid values */
- if (sr1 == -1 || sr2 == -1 || offset + bytes > CONFIG_FLASH_SIZE)
+ if (sr1 == 0xff || sr2 == 0xff || offset + bytes > CONFIG_FLASH_SIZE)
return EC_ERROR_INVAL;
/* Compute desired protect range */