@@ -122,10 +122,12 @@ int SPIFBlockDevice::init()
122
122
uint8_t vendor_device_ids[4 ];
123
123
size_t data_length = 3 ;
124
124
int status = SPIF_BD_ERROR_OK;
125
- struct sfdp_hdr_info hdr_info;
126
125
spif_bd_error spi_status = SPIF_BD_ERROR_OK;
127
126
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 ;
129
131
130
132
_mutex->lock ();
131
133
@@ -174,15 +176,17 @@ int SPIFBlockDevice::init()
174
176
}
175
177
176
178
/* *************************** 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 ) {
178
180
tr_error (" init - Parse SFDP Headers Failed" );
179
181
status = SPIF_BD_ERROR_PARSING_FAILED;
180
182
goto exit_point;
181
183
}
182
184
183
185
184
186
/* *************************** 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 ) {
186
190
tr_error (" init - Parse Basic Param Table Failed" );
187
191
status = SPIF_BD_ERROR_PARSING_FAILED;
188
192
goto exit_point;
@@ -193,9 +197,9 @@ int SPIFBlockDevice::init()
193
197
_device_size_bytes; // If there's no region map, we have a single region sized the entire device size
194
198
_sfdp_info.smptbl .region_high_boundary [0 ] = _device_size_bytes - 1 ;
195
199
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 );
199
203
if (sfdp_parse_sector_map_table (callback (this , &SPIFBlockDevice::_spi_send_read_sfdp_command),
200
204
_sfdp_info.smptbl ) < 0 ) {
201
205
tr_error (" init - Parse Sector Map Table Failed" );
0 commit comments