diff --git a/source/libs/fatfs/diskio.c b/source/libs/fatfs/diskio.c index 43c5b7d..1cf422d 100644 --- a/source/libs/fatfs/diskio.c +++ b/source/libs/fatfs/diskio.c @@ -89,7 +89,7 @@ DRESULT disk_write ( return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR; case DRIVE_BIS: - return nx_emmc_bis_write(sector, count, buff); + return nx_emmc_bis_write(sector, count, (void *)buff); } return RES_ERROR; diff --git a/source/storage/nx_emmc_bis.c b/source/storage/nx_emmc_bis.c index 85d9a96..22e90c3 100644 --- a/source/storage/nx_emmc_bis.c +++ b/source/storage/nx_emmc_bis.c @@ -365,10 +365,13 @@ void nx_emmc_bis_finalize() return; u32 limit = cache_filled == 1 ? MAX_CLUSTER_CACHE_ENTRIES : cluster_cache_end_index; - for (u32 i = 0; i < limit; i++) + u32 clusters_to_flush = dirty_cluster_count; + for (u32 i = 0; i < limit && clusters_to_flush; i++) { - if (bis_cache->cluster_cache[i].dirty) + if (bis_cache->cluster_cache[i].dirty) { _nx_emmc_bis_flush_cluster(&bis_cache->cluster_cache[i]); + clusters_to_flush--; + } } }