Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

storage: Misc corrections and cleanups

* Make the partial sector logic a little clearer (no functional change)
* Corrections for debugging messages
* Also use MAX_VIRT_SECTOR_SIZE in BOUNCE_BUFFER calculations

Change-Id: I89363824b092b2e3bddd5e0f75bf81200c9bc513

+54 -55
+1 -1
firmware/common/file.c
··· 120 120 int rc; 121 121 struct filestr_cache *cachep = file->stream.cachep; 122 122 123 - DEBUGF("Flushing dirty sector cache (%lu)\n", cachep->sector); 123 + DEBUGF("Flushing dirty sector cache (%llu)\n", (uint64_t)cachep->sector); 124 124 125 125 if (fat_query_sectornum(&file->stream.fatstr) != cachep->sector) 126 126 {
+46 -49
firmware/drivers/ata-common.c
··· 84 84 85 85 offset = start & (phys_sector_mult - 1); 86 86 87 - if (offset) /* first partial sector */ 87 + if (offset) /* first partial physical sector */ 88 88 { 89 89 int partcount = MIN(incount, phys_sector_mult - offset); 90 90 ··· 101 101 inbuf += partcount * log_sector_size; 102 102 incount -= partcount; 103 103 } 104 - if (incount) 105 - { 106 - offset = incount & (phys_sector_mult - 1); 107 - incount -= offset; 104 + offset = incount & (phys_sector_mult - 1); 105 + incount -= offset; 108 106 109 - if (incount) 107 + if (incount) /* all complete physical sectors */ 108 + { 109 + rc = ata_transfer_sectors(start, incount, inbuf, false); 110 + if (rc) 110 111 { 111 - rc = ata_transfer_sectors(start, incount, inbuf, false); 112 - if (rc) 113 - { 114 - rc = rc * 10 - 2; 115 - goto error; 116 - } 117 - start += incount; 118 - inbuf += incount * log_sector_size; 112 + rc = rc * 10 - 2; 113 + goto error; 119 114 } 120 - if (offset) 115 + start += incount; 116 + inbuf += incount * log_sector_size; 117 + } 118 + 119 + if (offset) /* Trailing partial logical sector */ 120 + { 121 + rc = cache_sector(start); 122 + if (rc) 121 123 { 122 - rc = cache_sector(start); 123 - if (rc) 124 - { 125 - rc = rc * 10 - 3; 126 - goto error; 127 - } 128 - memcpy(inbuf, sector_cache.data, offset * log_sector_size); 124 + rc = rc * 10 - 3; 125 + goto error; 129 126 } 127 + memcpy(inbuf, sector_cache.data, offset * log_sector_size); 130 128 } 131 129 132 130 error: ··· 150 148 151 149 offset = start & (phys_sector_mult - 1); 152 150 153 - if (offset) /* first partial sector */ 151 + if (offset) /* first partial physical sector */ 154 152 { 155 153 int partcount = MIN(count, phys_sector_mult - offset); 156 154 ··· 172 170 buf += partcount * log_sector_size; 173 171 count -= partcount; 174 172 } 175 - if (count) 173 + 174 + offset = count & (phys_sector_mult - 1); 175 + count -= offset; 176 + 177 + if (count) /* all complete physical sectors */ 176 178 { 177 - offset = count & (phys_sector_mult - 1); 178 - count -= offset; 179 + rc = ata_transfer_sectors(start, count, (void*)buf, true); 180 + if (rc) 181 + { 182 + rc = rc * 10 - 3; 183 + goto error; 184 + } 185 + start += count; 186 + buf += count * log_sector_size; 187 + } 179 188 180 - if (count) 189 + if (offset) /* Trailing partial logical sector */ 190 + { 191 + rc = cache_sector(start); 192 + if (rc) 181 193 { 182 - rc = ata_transfer_sectors(start, count, (void*)buf, true); 183 - if (rc) 184 - { 185 - rc = rc * 10 - 3; 186 - goto error; 187 - } 188 - start += count; 189 - buf += count * log_sector_size; 194 + rc = rc * 10 - 4; 195 + goto error; 190 196 } 191 - if (offset) 197 + memcpy(sector_cache.data, buf, offset * log_sector_size); 198 + rc = flush_current_sector(); 199 + if (rc) 192 200 { 193 - rc = cache_sector(start); 194 - if (rc) 195 - { 196 - rc = rc * 10 - 4; 197 - goto error; 198 - } 199 - memcpy(sector_cache.data, buf, offset * log_sector_size); 200 - rc = flush_current_sector(); 201 - if (rc) 202 - { 203 - rc = rc * 10 - 5; 204 - goto error; 205 - } 201 + rc = rc * 10 - 5; 202 + goto error; 206 203 } 207 204 } 208 205
+7 -5
firmware/drivers/fat.c
··· 278 278 } fat_bpbs[NUM_VOLUMES]; /* mounted partition info */ 279 279 280 280 #ifdef STORAGE_NEEDS_BOUNCE_BUFFER 281 - #if defined(MAX_VARIABLE_LOG_SECTOR) 281 + #if defined(MAX_VIRT_SETOR_SIZE) 282 + #define BOUNCE_SECTOR_SIZE MAX_VIRT_SECTOR_SIZE 283 + #elif defined(MAX_VARIABLE_LOG_SECTOR) 282 284 #define BOUNCE_SECTOR_SIZE MAX_VARIABLE_LOG_SECTOR 283 285 #elif defined(MAX_PHYS_SECTOR_SIZE) 284 286 #define BOUNCE_SECTOR_SIZE MAX_PHYS_SECTOR_SIZE ··· 1586 1588 union raw_dirent *srcent, uint8_t attr, 1587 1589 unsigned int flags) 1588 1590 { 1589 - DEBUGF("%s(file:%lx, first:%d, num:%d, name:%s)\n", __func__, 1591 + DEBUGF("%s(file:0x%lx, first:%d, num:%d, name:%s)\n", __func__, 1590 1592 file->firstcluster, file->e.entry - file->e.entries + 1, 1591 1593 file->e.entries, name); 1592 1594 ··· 2490 2492 2491 2493 if (rc < 0) 2492 2494 { 2493 - DEBUGF("Couldn't %s sector %lx (err %ld)\n", 2494 - write ? "write":"read", start, rc); 2495 + DEBUGF("Couldn't %s sector %llx (err %ld)\n", 2496 + write ? "write":"read", (uint64_t)start, rc); 2495 2497 return rc; 2496 2498 } 2497 2499 ··· 2518 2520 long clusternum = filestr->clusternum; 2519 2521 unsigned long sectornum = filestr->sectornum; 2520 2522 2521 - DEBUGF("%s(file:%lx,count:0x%lx,buf:%lx,%s)\n", __func__, 2523 + DEBUGF("%s(file:0x%lx,count:0x%lx,buf:%lx,%s)\n", __func__, 2522 2524 file->firstcluster, sectorcount, (long)buf, 2523 2525 write ? "write":"read"); 2524 2526 DEBUGF("%s: sec:%llx numsec:%ld eof:%d\n", __func__,