diff options
author | Martin Roth <martinroth@chromium.org> | 2016-08-15 15:03:07 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-09-01 05:02:27 -0700 |
commit | ce4f7ba59cd09dcb93c631797c62f3d8ebb0a4e4 (patch) | |
tree | eb3f9c826dd75629828c4574bce0e15d802d4750 /common/spi_nor.c | |
parent | 5e6da91fe86301d276b452a660139c27c3786a82 (diff) | |
download | chrome-ec-ce4f7ba59cd09dcb93c631797c62f3d8ebb0a4e4.tar.gz |
common/spi_nor.c: Don't update capacity or page_size after error
If there was an error getting the capacity or page size, don't update
the values with an incorrect/unknown/uninitialized value.
BUG=None
BRANCH=None
TEST=Build all boards successfully.
Change-Id: I907f14f219f721ec9e9753a38e4bf998bbc16324
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/370665
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Ewout van Bekkum <ewout@chromium.org>
Diffstat (limited to 'common/spi_nor.c')
-rw-r--r-- | common/spi_nor.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/common/spi_nor.c b/common/spi_nor.c index 9c0bec9523..dc69b19c3c 100644 --- a/common/spi_nor.c +++ b/common/spi_nor.c @@ -444,16 +444,17 @@ int spi_nor_init(void) spi_nor_device, table_major_rev, table_minor_rev, table_offset, &capacity); - - mutex_lock(&driver_mutex); - spi_nor_device->capacity = capacity; - spi_nor_device->page_size = page_size; - DEBUG_CPRINTS_DEVICE( - spi_nor_device, - "Updated to SFDP params: %dKiB w/ %dB pages", - spi_nor_device->capacity >> 10, - spi_nor_device->page_size); - mutex_unlock(&driver_mutex); + if (rv == EC_SUCCESS) { + mutex_lock(&driver_mutex); + spi_nor_device->capacity = capacity; + spi_nor_device->page_size = page_size; + DEBUG_CPRINTS_DEVICE( + spi_nor_device, + "Updated to SFDP params: %dKiB w/ %dB pages", + spi_nor_device->capacity >> 10, + spi_nor_device->page_size); + mutex_unlock(&driver_mutex); + } } /* Ensure the device is in a determined addressing state by @@ -764,7 +765,9 @@ static int command_spi_nor_info(int argc, char **argv) spi_nor_device->page_size); /* Get JEDEC ID info. */ - spi_nor_read_jedec_id(spi_nor_device, &mfn_bank, &mfn_id); + rv = spi_nor_read_jedec_id(spi_nor_device, &mfn_bank, &mfn_id); + if (rv != EC_SUCCESS) + return rv; ccprintf("\tJEDEC ID bank %d manufacturing code 0x%x\n", mfn_bank, mfn_id); |