Skip to content

Commit 98957cc

Browse files
committed
change unneeded uint8_t decls to size_t or uint32_t
1 parent 2fa97f3 commit 98957cc

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

supervisor/shared/external_flash/external_flash.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void supervisor_flash_init(void) {
211211
// Delay to give the SPI Flash time to get going.
212212
// TODO(tannewt): Only do this when we know power was applied vs a reset.
213213
uint16_t max_start_up_delay_us = 0;
214-
for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) {
214+
for (size_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) {
215215
if (possible_devices[i].start_up_time_us > max_start_up_delay_us) {
216216
max_start_up_delay_us = possible_devices[i].start_up_time_us;
217217
}
@@ -223,7 +223,7 @@ void supervisor_flash_init(void) {
223223
#ifdef EXTERNAL_FLASH_NO_JEDEC
224224
// For NVM that don't have JEDEC response
225225
spi_flash_command(CMD_WAKE);
226-
for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) {
226+
for (size_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) {
227227
const external_flash_device *possible_device = &possible_devices[i];
228228
flash_device = possible_device;
229229
break;
@@ -238,7 +238,7 @@ void supervisor_flash_init(void) {
238238
while ((count-- > 0) && (jedec_id_response[0] == 0xff || jedec_id_response[2] == 0x00)) {
239239
spi_flash_read_command(CMD_READ_JEDEC_ID, jedec_id_response, 3);
240240
}
241-
for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) {
241+
for (size_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) {
242242
const external_flash_device *possible_device = &possible_devices[i];
243243
if (jedec_id_response[0] == possible_device->manufacturer_id &&
244244
jedec_id_response[1] == possible_device->memory_type &&
@@ -327,7 +327,7 @@ static bool flush_scratch_flash(void) {
327327
// cached.
328328
bool copy_to_scratch_ok = true;
329329
uint32_t scratch_sector = flash_device->total_size - SPI_FLASH_ERASE_SIZE;
330-
for (uint8_t i = 0; i < BLOCKS_PER_SECTOR; i++) {
330+
for (size_t i = 0; i < BLOCKS_PER_SECTOR; i++) {
331331
if ((dirty_mask & (1 << i)) == 0) {
332332
copy_to_scratch_ok = copy_to_scratch_ok &&
333333
copy_block(current_sector + i * FILESYSTEM_BLOCK_SIZE,
@@ -342,7 +342,7 @@ static bool flush_scratch_flash(void) {
342342
// Second, erase the current sector.
343343
erase_sector(current_sector);
344344
// Finally, copy the new version into it.
345-
for (uint8_t i = 0; i < BLOCKS_PER_SECTOR; i++) {
345+
for (size_t i = 0; i < BLOCKS_PER_SECTOR; i++) {
346346
copy_block(scratch_sector + i * FILESYSTEM_BLOCK_SIZE,
347347
current_sector + i * FILESYSTEM_BLOCK_SIZE);
348348
}
@@ -416,9 +416,9 @@ static bool flush_ram_cache(bool keep_cache) {
416416
// we've cached. If we don't do this we'll erase the data during the sector
417417
// erase below.
418418
bool copy_to_ram_ok = true;
419-
for (uint8_t i = 0; i < BLOCKS_PER_SECTOR; i++) {
419+
for (size_t i = 0; i < BLOCKS_PER_SECTOR; i++) {
420420
if ((dirty_mask & (1 << i)) == 0) {
421-
for (uint8_t j = 0; j < PAGES_PER_BLOCK; j++) {
421+
for (size_t j = 0; j < PAGES_PER_BLOCK; j++) {
422422
copy_to_ram_ok = read_flash(
423423
current_sector + (i * PAGES_PER_BLOCK + j) * SPI_FLASH_PAGE_SIZE,
424424
flash_cache_table[i * PAGES_PER_BLOCK + j],
@@ -439,8 +439,8 @@ static bool flush_ram_cache(bool keep_cache) {
439439
// Second, erase the current sector.
440440
erase_sector(current_sector);
441441
// Lastly, write all the data in ram that we've cached.
442-
for (uint8_t i = 0; i < BLOCKS_PER_SECTOR; i++) {
443-
for (uint8_t j = 0; j < PAGES_PER_BLOCK; j++) {
442+
for (size_t i = 0; i < BLOCKS_PER_SECTOR; i++) {
443+
for (size_t j = 0; j < PAGES_PER_BLOCK; j++) {
444444
write_flash(current_sector + (i * PAGES_PER_BLOCK + j) * SPI_FLASH_PAGE_SIZE,
445445
flash_cache_table[i * PAGES_PER_BLOCK + j],
446446
SPI_FLASH_PAGE_SIZE);
@@ -497,8 +497,8 @@ static bool external_flash_read_block(uint8_t *dest, uint32_t block) {
497497

498498
// Mask out the lower bits that designate the address within the sector.
499499
uint32_t this_sector = address & (~(SPI_FLASH_ERASE_SIZE - 1));
500-
uint8_t block_index = (address / FILESYSTEM_BLOCK_SIZE) % BLOCKS_PER_SECTOR;
501-
uint8_t mask = 1 << (block_index);
500+
size_t block_index = (address / FILESYSTEM_BLOCK_SIZE) % BLOCKS_PER_SECTOR;
501+
uint32_t mask = 1 << (block_index);
502502
// We're reading from the currently cached sector.
503503
if (current_sector == this_sector && (mask & dirty_mask) > 0) {
504504
if (flash_cache_table != NULL) {
@@ -527,8 +527,8 @@ static bool external_flash_write_block(const uint8_t *data, uint32_t block) {
527527
wait_for_flash_ready();
528528
// Mask out the lower bits that designate the address within the sector.
529529
uint32_t this_sector = address & (~(SPI_FLASH_ERASE_SIZE - 1));
530-
uint8_t block_index = (address / FILESYSTEM_BLOCK_SIZE) % BLOCKS_PER_SECTOR;
531-
uint8_t mask = 1 << (block_index);
530+
size_t block_index = (address / FILESYSTEM_BLOCK_SIZE) % BLOCKS_PER_SECTOR;
531+
uint32_t mask = 1 << (block_index);
532532
// Flush the cache if we're moving onto a sector or we're writing the
533533
// same block again.
534534
if (current_sector != this_sector || (mask & dirty_mask) > 0) {

0 commit comments

Comments
 (0)