From e82f701fa469732cab1c549c23a025903ed8cbd7 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Fri, 6 Sep 2002 16:02:19 +0000 Subject: [PATCH] Optimized ata_read_sectors() a little git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2213 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata.c | 9 ++++++--- 1 file 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; }