Skip to content

Commit c41f7cb

Browse files
committed
Fix integer type warnings in SFDP and *SPIFBlockDevice
1 parent fb0f968 commit c41f7cb

File tree

5 files changed

+31
-32
lines changed

5 files changed

+31
-32
lines changed

drivers/include/drivers/internal/SFDP.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ int sfdp_find_addr_region(bd_addr_t offset, const sfdp_hdr_info &sfdp_info);
144144
* @return Largest erase type, or -1 if none matches the given address and size
145145
*/
146146
int sfdp_iterate_next_largest_erase_type(uint8_t bitfield,
147-
int size,
148-
int offset,
147+
bd_size_t size,
148+
bd_addr_t offset,
149149
int region,
150150
const sfdp_smptbl_info &smptbl);
151151

drivers/source/SFDP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ int sfdp_find_addr_region(bd_addr_t offset, const sfdp_hdr_info &sfdp_info)
394394
}
395395

396396
int sfdp_iterate_next_largest_erase_type(uint8_t bitfield,
397-
int size,
398-
int offset,
397+
bd_size_t size,
398+
bd_addr_t offset,
399399
int region,
400400
const sfdp_smptbl_info &smptbl)
401401
{

storage/blockdevice/COMPONENT_OSPIF/source/OSPIFBlockDevice.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "mbed_trace.h"
3232
#define TRACE_GROUP "OSPIF"
3333

34+
using namespace std::chrono;
3435
using namespace mbed;
3536

3637
/* Default OSPIF Parameters */
@@ -409,7 +410,7 @@ int OSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
409410
uint32_t chunk = 0;
410411
bd_size_t written_bytes = 0;
411412

412-
tr_debug("Program - Buff: 0x%lxh, addr: %llu, size: %llu", (uint32_t)buffer, addr, size);
413+
tr_debug("Program - Buff: %p, addr: %llu, size: %llu", buffer, addr, size);
413414

414415
while (size > 0) {
415416
// Write on _page_size_bytes boundaries (Default 256 bytes a page)
@@ -457,26 +458,25 @@ int OSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
457458
return status;
458459
}
459460

460-
int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
461+
int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t size)
461462
{
462463
int type = 0;
463464
ospi_inst_t cur_erase_inst = OSPI_NO_INST;
464-
int size = (int)in_size;
465465
bool erase_failed = false;
466466
int status = OSPIF_BD_ERROR_OK;
467467
// Find region of erased address
468468
int region = sfdp_find_addr_region(addr, _sfdp_info);
469469
// Erase Types of selected region
470470
uint8_t bitfield = _sfdp_info.smptbl.region_erase_types_bitfld[region];
471471

472-
tr_debug("Erase - addr: %llu, in_size: %llu", addr, in_size);
472+
tr_debug("Erase - addr: %llu, size: %llu", addr, size);
473473

474-
if ((addr + in_size) > _sfdp_info.bptbl.device_size_bytes) {
474+
if ((addr + size) > _sfdp_info.bptbl.device_size_bytes) {
475475
tr_error("Erase exceeds flash device size");
476476
return OSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
477477
}
478478

479-
if (((addr % get_erase_size(addr)) != 0) || (((addr + in_size) % get_erase_size(addr + in_size - 1)) != 0)) {
479+
if (((addr % get_erase_size(addr)) != 0) || (((addr + size) % get_erase_size(addr + size - 1)) != 0)) {
480480
tr_error("Invalid erase - unaligned address and size");
481481
return OSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
482482
}
@@ -502,11 +502,11 @@ int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
502502
if (addr % eu_size != 0 || addr + size < eu_size) {
503503
// Should not happen if the erase table parsing
504504
// and alignment checks were performed correctly
505-
tr_error("internal error: address %llu not aligned to erase size %llu (type %d)",
505+
tr_error("internal error: address %llu not aligned to erase size %u (type %d)",
506506
addr, eu_size, type);
507507
}
508508

509-
tr_debug("Erase - addr: %llu, size:%d, Inst: 0x%xh, erase size: %lu ",
509+
tr_debug("Erase - addr: %llu, size:%llu, Inst: 0x%xh, erase size: %u ",
510510
addr, size, cur_erase_inst, eu_size);
511511
tr_debug("Erase - Region: %d, Type:%d ",
512512
region, type);
@@ -1520,7 +1520,7 @@ bool OSPIFBlockDevice::_is_mem_ready()
15201520
bool mem_ready = true;
15211521

15221522
do {
1523-
rtos::ThisThread::sleep_for(1);
1523+
rtos::ThisThread::sleep_for(1ms);
15241524
retries++;
15251525
//Read Status Register 1 from device, the number of read byte need to be even in octa flash DOPI mode
15261526
if (OSPI_STATUS_OK != _ospi_send_general_command(OSPIF_INST_RSR1, OSPI_NO_ADDRESS_COMMAND,
@@ -1668,7 +1668,7 @@ ospi_status_t OSPIFBlockDevice::_ospi_send_general_command(ospi_inst_t instructi
16681668
_ospi.configure_format(_inst_width, _inst_size, _address_width, _address_size, OSPI_CFG_BUS_SINGLE,
16691669
0, _data_width, 4);
16701670
addr = 0;
1671-
} else if ((instruction == OSPIF_INST_WSR1)) {
1671+
} else if (instruction == OSPIF_INST_WSR1) {
16721672
addr = 0;
16731673
}
16741674
}

storage/blockdevice/COMPONENT_QSPIF/source/QSPIFBlockDevice.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ int QSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
338338
uint32_t chunk = 0;
339339
bd_size_t written_bytes = 0;
340340

341-
tr_debug("Program - Buff: 0x%lxh, addr: %llu, size: %llu", (uint32_t)buffer, addr, size);
341+
tr_debug("Program - Buff: %p, addr: %llu, size: %llu", buffer, addr, size);
342342

343343
while (size > 0) {
344344
// Write on _page_size_bytes boundaries (Default 256 bytes a page)
@@ -385,26 +385,25 @@ int QSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
385385
return status;
386386
}
387387

388-
int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
388+
int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t size)
389389
{
390390
int type = 0;
391391
qspi_inst_t cur_erase_inst = QSPI_NO_INST;
392-
int size = (int)in_size;
393392
bool erase_failed = false;
394393
int status = QSPIF_BD_ERROR_OK;
395394
// Find region of erased address
396395
int region = sfdp_find_addr_region(addr, _sfdp_info);
397396
// Erase Types of selected region
398397
uint8_t bitfield = _sfdp_info.smptbl.region_erase_types_bitfld[region];
399398

400-
tr_debug("Erase - addr: %llu, in_size: %llu", addr, in_size);
399+
tr_debug("Erase - addr: %llu, size: %llu", addr, size);
401400

402-
if ((addr + in_size) > _sfdp_info.bptbl.device_size_bytes) {
401+
if ((addr + size) > _sfdp_info.bptbl.device_size_bytes) {
403402
tr_error("Erase exceeds flash device size");
404403
return QSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
405404
}
406405

407-
if (((addr % get_erase_size(addr)) != 0) || (((addr + in_size) % get_erase_size(addr + in_size - 1)) != 0)) {
406+
if (((addr % get_erase_size(addr)) != 0) || (((addr + size) % get_erase_size(addr + size - 1)) != 0)) {
408407
tr_error("Invalid erase - unaligned address and size");
409408
return QSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
410409
}
@@ -415,7 +414,7 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
415414
if (_sfdp_info.bptbl.legacy_erase_instruction == QSPI_NO_INST) {
416415
// Iterate to find next largest erase type that is a) supported by region, and b) smaller than size.
417416
// Find the matching instruction and erase size chunk for that type.
418-
type = sfdp_iterate_next_largest_erase_type(bitfield, size, (int)addr,
417+
type = sfdp_iterate_next_largest_erase_type(bitfield, size, addr,
419418
region,
420419
_sfdp_info.smptbl);
421420
cur_erase_inst = _sfdp_info.smptbl.erase_type_inst_arr[type];
@@ -429,11 +428,11 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
429428
if (addr % eu_size != 0 || addr + size < eu_size) {
430429
// Should not happen if the erase table parsing
431430
// and alignment checks were performed correctly
432-
tr_error("internal error: address %llu not aligned to erase size %llu (type %d)",
431+
tr_error("internal error: address %llu not aligned to erase size %u (type %d)",
433432
addr, eu_size, type);
434433
}
435434

436-
tr_debug("Erase - addr: %llu, size:%d, Inst: 0x%xh, erase size: %lu ",
435+
tr_debug("Erase - addr: %llu, size:%llu, Inst: 0x%xh, erase size: %u",
437436
addr, size, cur_erase_inst, eu_size);
438437
tr_debug("Erase - Region: %d, Type:%d ",
439438
region, type);

storage/blockdevice/COMPONENT_SPIF/source/SPIFBlockDevice.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "mbed_trace.h"
2727
#define TRACE_GROUP "SPIF"
28+
using namespace std::chrono;
2829
using namespace mbed;
2930

3031
/* Default SPIF Parameters */
@@ -298,7 +299,7 @@ int SPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size)
298299
return status;
299300
}
300301

301-
int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
302+
int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t size)
302303
{
303304
if (!_is_initialized) {
304305
return BD_ERROR_DEVICE_ERROR;
@@ -307,7 +308,6 @@ int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
307308
int type = 0;
308309
int cur_erase_inst = _erase_instruction;
309310
unsigned int curr_erase_size = 0;
310-
int size = (int)in_size;
311311
bool erase_failed = false;
312312
int status = SPIF_BD_ERROR_OK;
313313
// Find region of erased address
@@ -319,14 +319,14 @@ int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
319319
// Erase Types of selected region
320320
uint8_t bitfield = _sfdp_info.smptbl.region_erase_types_bitfld[region];
321321

322-
tr_debug("erase - addr: %llu, in_size: %llu", addr, in_size);
322+
tr_debug("erase - addr: %llu, size: %llu", addr, size);
323323

324-
if ((addr + in_size) > _sfdp_info.bptbl.device_size_bytes) {
324+
if ((addr + size) > _sfdp_info.bptbl.device_size_bytes) {
325325
tr_error("erase exceeds flash device size");
326326
return SPIF_BD_ERROR_INVALID_ERASE_PARAMS;
327327
}
328328

329-
if (((addr % get_erase_size(addr)) != 0) || (((addr + in_size) % get_erase_size(addr + in_size - 1)) != 0)) {
329+
if (((addr % get_erase_size(addr)) != 0) || (((addr + size) % get_erase_size(addr + size - 1)) != 0)) {
330330
tr_error("invalid erase - unaligned address and size");
331331
return SPIF_BD_ERROR_INVALID_ERASE_PARAMS;
332332
}
@@ -336,17 +336,17 @@ int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
336336

337337
// iterate to find next Largest erase type ( a. supported by region, b. smaller than size)
338338
// find the matching instruction and erase size chunk for that type.
339-
type = sfdp_iterate_next_largest_erase_type(bitfield, size, (unsigned int)addr, region, _sfdp_info.smptbl);
339+
type = sfdp_iterate_next_largest_erase_type(bitfield, size, addr, region, _sfdp_info.smptbl);
340340
cur_erase_inst = _sfdp_info.smptbl.erase_type_inst_arr[type];
341341
curr_erase_size = _sfdp_info.smptbl.erase_type_size_arr[type];
342342
if (addr % curr_erase_size != 0 || addr + size < curr_erase_size) {
343343
// Should not happen if the erase table parsing
344344
// and alignment checks were performed correctly
345-
tr_error("internal error: address %llu not aligned to erase size %llu (type %d)",
345+
tr_error("internal error: address %llu not aligned to erase size %u (type %d)",
346346
addr, curr_erase_size, type);
347347
}
348348

349-
tr_debug("erase - addr: %llu, size:%d, Inst: 0x%xh, erase size: %" PRIu32 " , ",
349+
tr_debug("erase - addr: %llu, size:%llu, Inst: 0x%xh, erase size: %u",
350350
addr, size, cur_erase_inst, curr_erase_size);
351351
tr_debug("erase - Region: %d, Type:%d",
352352
region, type);
@@ -696,7 +696,7 @@ bool SPIFBlockDevice::_is_mem_ready()
696696
bool mem_ready = true;
697697

698698
do {
699-
rtos::ThisThread::sleep_for(1);
699+
rtos::ThisThread::sleep_for(1ms);
700700
retries++;
701701
//Read the Status Register from device
702702
if (SPIF_BD_ERROR_OK != _spi_send_general_command(SPIF_RDSR, SPI_NO_ADDRESS_COMMAND, NULL, 0, status_value,

0 commit comments

Comments
 (0)