diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-09-06 16:02:19 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-09-06 16:02:19 +0000 |
commit | e82f701fa469732cab1c549c23a025903ed8cbd7 (patch) | |
tree | 7347f109a52bdee74324aea3d2cdcfd749ce5aca /firmware/drivers | |
parent | 8b01f614a81156138ef8b985b07100607d96e63e (diff) |
Optimized ata_read_sectors() a little
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2213 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/ata.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 8d892788a9..32048ef53d 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -210,6 +210,7 @@ int ata_read_sectors(unsigned long start, while (count) { int j; int sectors; + int wordcount; if (!wait_for_start_of_transfer()) { @@ -226,15 +227,17 @@ int ata_read_sectors(unsigned long start, else sectors = count; + wordcount = sectors * SECTOR_SIZE / 2; + if ( (unsigned int)buf & 1 ) { - for (j=0; j < sectors * SECTOR_SIZE / 2; j++) { + for (j=0; j < wordcount; j++) { unsigned short tmp = SWAB16(ATA_DATA); ((unsigned char*)buf)[j*2] = tmp >> 8; ((unsigned char*)buf)[j*2+1] = tmp & 0xff; } } else { - for (j=0; j < sectors * SECTOR_SIZE / 2; j++) + for (j=0; j < wordcount; j++) ((unsigned short*)buf)[j] = SWAB16(ATA_DATA); } @@ -242,7 +245,7 @@ int ata_read_sectors(unsigned long start, /* reading the status register clears the interrupt */ j = ATA_STATUS; #endif - buf += sectors * SECTOR_SIZE; /* Advance one sector */ + buf += sectors * SECTOR_SIZE; /* Advance one chunk of sectors */ count -= sectors; } |