mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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
This commit is contained in:
parent
127b583a4d
commit
dfbbfb12d4
3 changed files with 55 additions and 56 deletions
|
@ -120,7 +120,7 @@ static int flush_cache(struct filestr_desc *file)
|
|||
int rc;
|
||||
struct filestr_cache *cachep = file->stream.cachep;
|
||||
|
||||
DEBUGF("Flushing dirty sector cache (%lu)\n", cachep->sector);
|
||||
DEBUGF("Flushing dirty sector cache (%llu)\n", (uint64_t)cachep->sector);
|
||||
|
||||
if (fat_query_sectornum(&file->stream.fatstr) != cachep->sector)
|
||||
{
|
||||
|
|
|
@ -84,7 +84,7 @@ int ata_read_sectors(IF_MD(int drive,)
|
|||
|
||||
offset = start & (phys_sector_mult - 1);
|
||||
|
||||
if (offset) /* first partial sector */
|
||||
if (offset) /* first partial physical sector */
|
||||
{
|
||||
int partcount = MIN(incount, phys_sector_mult - offset);
|
||||
|
||||
|
@ -101,12 +101,10 @@ int ata_read_sectors(IF_MD(int drive,)
|
|||
inbuf += partcount * log_sector_size;
|
||||
incount -= partcount;
|
||||
}
|
||||
if (incount)
|
||||
{
|
||||
offset = incount & (phys_sector_mult - 1);
|
||||
incount -= offset;
|
||||
|
||||
if (incount)
|
||||
if (incount) /* all complete physical sectors */
|
||||
{
|
||||
rc = ata_transfer_sectors(start, incount, inbuf, false);
|
||||
if (rc)
|
||||
|
@ -117,7 +115,8 @@ int ata_read_sectors(IF_MD(int drive,)
|
|||
start += incount;
|
||||
inbuf += incount * log_sector_size;
|
||||
}
|
||||
if (offset)
|
||||
|
||||
if (offset) /* Trailing partial logical sector */
|
||||
{
|
||||
rc = cache_sector(start);
|
||||
if (rc)
|
||||
|
@ -127,7 +126,6 @@ int ata_read_sectors(IF_MD(int drive,)
|
|||
}
|
||||
memcpy(inbuf, sector_cache.data, offset * log_sector_size);
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
mutex_unlock(&ata_mutex);
|
||||
|
@ -150,7 +148,7 @@ int ata_write_sectors(IF_MD(int drive,)
|
|||
|
||||
offset = start & (phys_sector_mult - 1);
|
||||
|
||||
if (offset) /* first partial sector */
|
||||
if (offset) /* first partial physical sector */
|
||||
{
|
||||
int partcount = MIN(count, phys_sector_mult - offset);
|
||||
|
||||
|
@ -172,12 +170,11 @@ int ata_write_sectors(IF_MD(int drive,)
|
|||
buf += partcount * log_sector_size;
|
||||
count -= partcount;
|
||||
}
|
||||
if (count)
|
||||
{
|
||||
|
||||
offset = count & (phys_sector_mult - 1);
|
||||
count -= offset;
|
||||
|
||||
if (count)
|
||||
if (count) /* all complete physical sectors */
|
||||
{
|
||||
rc = ata_transfer_sectors(start, count, (void*)buf, true);
|
||||
if (rc)
|
||||
|
@ -188,7 +185,8 @@ int ata_write_sectors(IF_MD(int drive,)
|
|||
start += count;
|
||||
buf += count * log_sector_size;
|
||||
}
|
||||
if (offset)
|
||||
|
||||
if (offset) /* Trailing partial logical sector */
|
||||
{
|
||||
rc = cache_sector(start);
|
||||
if (rc)
|
||||
|
@ -204,7 +202,6 @@ int ata_write_sectors(IF_MD(int drive,)
|
|||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
mutex_unlock(&ata_mutex);
|
||||
|
|
|
@ -278,7 +278,9 @@ static struct bpb
|
|||
} fat_bpbs[NUM_VOLUMES]; /* mounted partition info */
|
||||
|
||||
#ifdef STORAGE_NEEDS_BOUNCE_BUFFER
|
||||
#if defined(MAX_VARIABLE_LOG_SECTOR)
|
||||
#if defined(MAX_VIRT_SETOR_SIZE)
|
||||
#define BOUNCE_SECTOR_SIZE MAX_VIRT_SECTOR_SIZE
|
||||
#elif defined(MAX_VARIABLE_LOG_SECTOR)
|
||||
#define BOUNCE_SECTOR_SIZE MAX_VARIABLE_LOG_SECTOR
|
||||
#elif defined(MAX_PHYS_SECTOR_SIZE)
|
||||
#define BOUNCE_SECTOR_SIZE MAX_PHYS_SECTOR_SIZE
|
||||
|
@ -1586,7 +1588,7 @@ static int write_longname(struct bpb *fat_bpb, struct fat_filestr *parentstr,
|
|||
union raw_dirent *srcent, uint8_t attr,
|
||||
unsigned int flags)
|
||||
{
|
||||
DEBUGF("%s(file:%lx, first:%d, num:%d, name:%s)\n", __func__,
|
||||
DEBUGF("%s(file:0x%lx, first:%d, num:%d, name:%s)\n", __func__,
|
||||
file->firstcluster, file->e.entry - file->e.entries + 1,
|
||||
file->e.entries, name);
|
||||
|
||||
|
@ -2490,8 +2492,8 @@ static long transfer(struct bpb *fat_bpb, sector_t start, long count,
|
|||
|
||||
if (rc < 0)
|
||||
{
|
||||
DEBUGF("Couldn't %s sector %lx (err %ld)\n",
|
||||
write ? "write":"read", start, rc);
|
||||
DEBUGF("Couldn't %s sector %llx (err %ld)\n",
|
||||
write ? "write":"read", (uint64_t)start, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -2518,7 +2520,7 @@ long fat_readwrite(struct fat_filestr *filestr, unsigned long sectorcount,
|
|||
long clusternum = filestr->clusternum;
|
||||
unsigned long sectornum = filestr->sectornum;
|
||||
|
||||
DEBUGF("%s(file:%lx,count:0x%lx,buf:%lx,%s)\n", __func__,
|
||||
DEBUGF("%s(file:0x%lx,count:0x%lx,buf:%lx,%s)\n", __func__,
|
||||
file->firstcluster, sectorcount, (long)buf,
|
||||
write ? "write":"read");
|
||||
DEBUGF("%s: sec:%llx numsec:%ld eof:%d\n", __func__,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue