mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 10:00:51 +00:00
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user