Skip to content

Commit 6d77d0d

Browse files
author
Veijo Pesonen
committed
SPIFBlockDevice: Consolidates internal SFDP header information
1 parent fe49c9c commit 6d77d0d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ int SPIFBlockDevice::init()
122122
uint8_t vendor_device_ids[4];
123123
size_t data_length = 3;
124124
int status = SPIF_BD_ERROR_OK;
125-
struct sfdp_hdr_info hdr_info;
126125
spif_bd_error spi_status = SPIF_BD_ERROR_OK;
127126

128-
memset(&hdr_info, 0, sizeof hdr_info);
127+
_sfdp_info.bptbl.addr = 0x0;
128+
_sfdp_info.bptbl.size = 0;
129+
_sfdp_info.smptbl.addr = 0x0;
130+
_sfdp_info.smptbl.size = 0;
129131

130132
_mutex->lock();
131133

@@ -174,15 +176,17 @@ int SPIFBlockDevice::init()
174176
}
175177

176178
/**************************** Parse SFDP Header ***********************************/
177-
if (0 != sfdp_parse_headers(callback(this, &SPIFBlockDevice::_spi_send_read_sfdp_command), hdr_info)) {
179+
if (sfdp_parse_headers(callback(this, &SPIFBlockDevice::_spi_send_read_sfdp_command), _sfdp_info) < 0) {
178180
tr_error("init - Parse SFDP Headers Failed");
179181
status = SPIF_BD_ERROR_PARSING_FAILED;
180182
goto exit_point;
181183
}
182184

183185

184186
/**************************** Parse Basic Parameters Table ***********************************/
185-
if (0 != _sfdp_parse_basic_param_table(callback(this, &SPIFBlockDevice::_spi_send_read_sfdp_command), hdr_info.bptbl.addr, hdr_info.bptbl.size)) {
187+
if (_sfdp_parse_basic_param_table(callback(this, &SPIFBlockDevice::_spi_send_read_sfdp_command),
188+
_sfdp_info.bptbl.addr,
189+
_sfdp_info.bptbl.size) < 0) {
186190
tr_error("init - Parse Basic Param Table Failed");
187191
status = SPIF_BD_ERROR_PARSING_FAILED;
188192
goto exit_point;
@@ -193,9 +197,9 @@ int SPIFBlockDevice::init()
193197
_device_size_bytes; // If there's no region map, we have a single region sized the entire device size
194198
_sfdp_info.smptbl.region_high_boundary[0] = _device_size_bytes - 1;
195199

196-
if ((hdr_info.smptbl.addr != 0) && (0 != hdr_info.smptbl.size)) {
197-
tr_debug("init - Parsing Sector Map Table - addr: 0x%" PRIx32 "h, Size: %d", hdr_info.smptbl.addr,
198-
hdr_info.smptbl.size);
200+
if ((_sfdp_info.smptbl.addr != 0) && (0 != _sfdp_info.smptbl.size)) {
201+
tr_debug("init - Parsing Sector Map Table - addr: 0x%" PRIx32 "h, Size: %d", _sfdp_info.smptbl.addr,
202+
_sfdp_info.smptbl.size);
199203
if (sfdp_parse_sector_map_table(callback(this, &SPIFBlockDevice::_spi_send_read_sfdp_command),
200204
_sfdp_info.smptbl) < 0) {
201205
tr_error("init - Parse Sector Map Table Failed");

0 commit comments

Comments
 (0)