summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-05-19 12:11:57 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-05-19 12:11:57 +0000
commitb3a8170afef84b545b7df17ff7d87d3f8528bae7 (patch)
tree0937fb6631accf3575982dc322a0071c574be910 /firmware
parent6f2afd36bc3ad1dfe6a747060e4575caa186c010 (diff)
downloadrockbox-b3a8170afef84b545b7df17ff7d87d3f8528bae7.tar.gz
rockbox-b3a8170afef84b545b7df17ff7d87d3f8528bae7.tar.bz2
rockbox-b3a8170afef84b545b7df17ff7d87d3f8528bae7.zip
sd-as3525: avoid division when calculating current bank, we only deal with 1 or 2 banks
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26161 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/sd-as3525.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index 2b299f182d..ac359f3f85 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -105,7 +105,7 @@ static int sd_select_bank(signed char bank);
static int sd_init_card(const int drive);
static void init_pl180_controller(const int drive);
-#define BLOCKS_PER_BANK 0x7a7800
+#define BLOCKS_PER_BANK 0x7a7800u
static tCardInfo card_info[NUM_DRIVES];
@@ -712,7 +712,12 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
/* Only switch banks for internal storage */
if(drive == INTERNAL_AS3525)
{
- unsigned int bank = start / BLOCKS_PER_BANK; /* Current bank */
+ unsigned int bank = 0;
+ while(bank_start >= BLOCKS_PER_BANK)
+ {
+ bank_start -= BLOCKS_PER_BANK;
+ bank++;
+ }
/* Switch bank if needed */
if(card_info[INTERNAL_AS3525].current_bank != bank)
@@ -725,9 +730,6 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
}
}
- /* Adjust start block in current bank */
- bank_start -= bank * BLOCKS_PER_BANK;
-
/* Do not cross a bank boundary in a single transfer loop */
if((transfer + bank_start) > BLOCKS_PER_BANK)
transfer = BLOCKS_PER_BANK - bank_start;