diff options
| author | Jack Halpin <jack.halpin@gmail.com> | 2009-11-24 17:43:53 +0000 |
|---|---|---|
| committer | Jack Halpin <jack.halpin@gmail.com> | 2009-11-24 17:43:53 +0000 |
| commit | cb9dff0a95cc98d83d6e1445c20bdad53614fe00 (patch) | |
| tree | 960f0c1cc1225ed47e30f90cc160e6899cb99dd4 | |
| parent | 1511d75f9d965cba0e1ef9d2fddb94149196638c (diff) | |
| download | rockbox-cb9dff0a95cc98d83d6e1445c20bdad53614fe00.zip rockbox-cb9dff0a95cc98d83d6e1445c20bdad53614fe00.tar.gz rockbox-cb9dff0a95cc98d83d6e1445c20bdad53614fe00.tar.bz2 rockbox-cb9dff0a95cc98d83d6e1445c20bdad53614fe00.tar.xz | |
AMS Sansa: Include time spent yielding when figuring timeout in sd_wait_for_state().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23738 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/target/arm/as3525/ata_sd_as3525.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c index 9f2514d..e71c886 100644 --- a/firmware/target/arm/as3525/ata_sd_as3525.c +++ b/firmware/target/arm/as3525/ata_sd_as3525.c @@ -539,13 +539,10 @@ bool sd_present(IF_MD_NONVOID(int drive)) static int sd_wait_for_state(const int drive, unsigned int state) { unsigned long response = 0; - unsigned int timeout = 100; /* ticks */ - long t = current_tick; + unsigned int timeout = current_tick + 100; /* 100 ticks timeout */ while (1) { - long tick; - if(!send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, MCI_RESP|MCI_ARG, &response)) return -1; @@ -553,14 +550,13 @@ static int sd_wait_for_state(const int drive, unsigned int state) if (((response >> 9) & 0xf) == state) return 0; - if(TIME_AFTER(current_tick, t + timeout)) + if(TIME_AFTER(current_tick, timeout)) return -2; - if (TIME_AFTER((tick = current_tick), next_yield)) + if (TIME_AFTER(current_tick, next_yield)) { yield(); - timeout += current_tick - tick; - next_yield = tick + MIN_YIELD_PERIOD; + next_yield = current_tick + MIN_YIELD_PERIOD; } } } |