Skip to content

Commit 5d7599a

Browse files
author
Kyle Kearney
committed
Report errors returned by _qspi_configure_format
The function returns a qspi_status_t but most usages in QSPIFBlockDevice assume that it always succeeds.
1 parent c094ad8 commit 5d7599a

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,11 @@ int QSPIFBlockDevice::init()
247247
}
248248

249249
// Configure BUS Mode to 1_1_1 for all commands other than Read
250-
_qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
251-
0, QSPI_CFG_BUS_SINGLE, 0);
250+
if (QSPI_STATUS_OK != _qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
251+
0, QSPI_CFG_BUS_SINGLE, 0)) {
252+
status = QSPIF_BD_ERROR_CONF_FORMAT_FAILED;
253+
goto exit_point;
254+
}
252255

253256
_is_initialized = true;
254257

@@ -303,17 +306,21 @@ int QSPIFBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
303306
_mutex.lock();
304307

305308
// Configure Bus for Reading
306-
_qspi_configure_format(_inst_width, _address_width, _address_size, _address_width, // Alt width == address width
307-
_alt_size, _data_width, _dummy_cycles);
309+
if (QSPI_STATUS_OK != _qspi_configure_format(_inst_width, _address_width, _address_size, _address_width, // Alt width == address width
310+
_alt_size, _data_width, _dummy_cycles) {
311+
return QSPIF_BD_ERROR_CONF_FORMAT_FAILED;
312+
}
308313

309314
if (QSPI_STATUS_OK != _qspi_send_read_command(_read_instruction, buffer, addr, size)) {
310-
status = QSPIF_BD_ERROR_DEVICE_ERROR;
311315
tr_error("Read Command failed");
316+
return QSPIF_BD_ERROR_DEVICE_ERROR;
312317
}
313318

314319
// All commands other than Read use default 1-1-1 Bus mode (Program/Erase are constrained by flash memory performance more than bus performance)
315-
_qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
316-
0, QSPI_CFG_BUS_SINGLE, 0);
320+
if (QSPI_STATUS_OK != _qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
321+
0, QSPI_CFG_BUS_SINGLE, 0)) {
322+
return QSPIF_BD_ERROR_CONF_FORMAT_FAILED;
323+
}
317324

318325
_mutex.unlock();
319326
return status;
@@ -718,8 +725,10 @@ int QSPIFBlockDevice::_sfdp_parse_sfdp_headers(uint32_t &basic_table_addr, size_
718725
bd_addr_t addr = 0x0;
719726

720727
// Set 1-1-1 bus mode for SFDP header parsing
721-
_qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
722-
0, QSPI_CFG_BUS_SINGLE, 8);
728+
if (QSPI_STATUS_OK != _qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
729+
0, QSPI_CFG_BUS_SINGLE, 8)) {
730+
return -1;
731+
}
723732

724733
qspi_status_t status = _qspi_send_read_command(QSPIF_SFDP, (char *)sfdp_header, addr /*address*/, data_length);
725734
if (status != QSPI_STATUS_OK) {
@@ -885,8 +894,10 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr)
885894
}
886895

887896
// Configure BUS Mode to 1_1_1 for all commands other than Read
888-
_qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
889-
0, QSPI_CFG_BUS_SINGLE, 0);
897+
if (QSPI_STATUS_OK != _qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
898+
0, QSPI_CFG_BUS_SINGLE, 0)) {
899+
return -1;
900+
}
890901

891902
// Read Status Register
892903
if (QSPI_STATUS_OK == _qspi_send_general_command(_read_register_inst, QSPI_NO_ADDRESS_COMMAND, NULL, 0,
@@ -1211,8 +1222,11 @@ int QSPIFBlockDevice::_enable_fast_mdoe()
12111222
status_reg_qer_setup[2] = 0x2; // Bit 1 of config Reg 2
12121223

12131224
// Configure BUS Mode to 1_1_1 for all commands other than Read
1214-
_qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
1215-
0, QSPI_CFG_BUS_SINGLE, 0);
1225+
if (QSPI_STATUS_OK != _qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
1226+
0, QSPI_CFG_BUS_SINGLE, 0)) {
1227+
tr_error("_qspi_configure_format failed");
1228+
return QSPIF_BD_ERROR_CONF_FORMAT_FAILED;
1229+
}
12161230

12171231
// Read Status Register
12181232
if (QSPI_STATUS_OK == _qspi_send_general_command(read_conf_register_inst, QSPI_NO_ADDRESS_COMMAND, NULL, 0,

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ enum qspif_bd_error {
2929
QSPIF_BD_ERROR_PARSING_FAILED = -4002, /* SFDP Parsing failed */
3030
QSPIF_BD_ERROR_READY_FAILED = -4003, /* Wait for Mem Ready failed */
3131
QSPIF_BD_ERROR_WREN_FAILED = -4004, /* Write Enable Failed */
32-
QSPIF_BD_ERROR_INVALID_ERASE_PARAMS = -4005, /* Erase command not on sector aligned addresses or exceeds device size */
33-
QSPIF_BD_ERROR_DEVICE_NOT_UNIQE = -4006, /* Only one instance per csel is allowed */
34-
QSPIF_BD_ERROR_DEVICE_MAX_EXCEED = -4007 /* Max active QSPIF devices exceeded */
32+
QSPIF_BD_ERROR_CONF_FORMAT_FAILED = -4005, /* Configure format failed */
33+
QSPIF_BD_ERROR_INVALID_ERASE_PARAMS = -4006, /* Erase command not on sector aligned addresses or exceeds device size */
34+
QSPIF_BD_ERROR_DEVICE_NOT_UNIQE = -4007, /* Only one instance per csel is allowed */
35+
QSPIF_BD_ERROR_DEVICE_MAX_EXCEED = -4008 /* Max active QSPIF devices exceeded */
3536
};
3637

3738
/** Enum qspif polarity mode

0 commit comments

Comments
 (0)