summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
105static int sd_init_card(const int drive); 105static int sd_init_card(const int drive);
106static void init_pl180_controller(const int drive); 106static void init_pl180_controller(const int drive);
107 107
108#define BLOCKS_PER_BANK 0x7a7800 108#define BLOCKS_PER_BANK 0x7a7800u
109 109
110static tCardInfo card_info[NUM_DRIVES]; 110static tCardInfo card_info[NUM_DRIVES];
111 111
@@ -712,7 +712,12 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
712 /* Only switch banks for internal storage */ 712 /* Only switch banks for internal storage */
713 if(drive == INTERNAL_AS3525) 713 if(drive == INTERNAL_AS3525)
714 { 714 {
715 unsigned int bank = start / BLOCKS_PER_BANK; /* Current bank */ 715 unsigned int bank = 0;
716 while(bank_start >= BLOCKS_PER_BANK)
717 {
718 bank_start -= BLOCKS_PER_BANK;
719 bank++;
720 }
716 721
717 /* Switch bank if needed */ 722 /* Switch bank if needed */
718 if(card_info[INTERNAL_AS3525].current_bank != bank) 723 if(card_info[INTERNAL_AS3525].current_bank != bank)
@@ -725,9 +730,6 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
725 } 730 }
726 } 731 }
727 732
728 /* Adjust start block in current bank */
729 bank_start -= bank * BLOCKS_PER_BANK;
730
731 /* Do not cross a bank boundary in a single transfer loop */ 733 /* Do not cross a bank boundary in a single transfer loop */
732 if((transfer + bank_start) > BLOCKS_PER_BANK) 734 if((transfer + bank_start) > BLOCKS_PER_BANK)
733 transfer = BLOCKS_PER_BANK - bank_start; 735 transfer = BLOCKS_PER_BANK - bank_start;