forked from len0rd/rockbox
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
This commit is contained in:
parent
1511d75f9d
commit
cb9dff0a95
1 changed files with 4 additions and 8 deletions
|
|
@ -539,13 +539,10 @@ bool sd_present(IF_MD_NONVOID(int drive))
|
||||||
static int sd_wait_for_state(const int drive, unsigned int state)
|
static int sd_wait_for_state(const int drive, unsigned int state)
|
||||||
{
|
{
|
||||||
unsigned long response = 0;
|
unsigned long response = 0;
|
||||||
unsigned int timeout = 100; /* ticks */
|
unsigned int timeout = current_tick + 100; /* 100 ticks timeout */
|
||||||
long t = current_tick;
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
long tick;
|
|
||||||
|
|
||||||
if(!send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca,
|
if(!send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca,
|
||||||
MCI_RESP|MCI_ARG, &response))
|
MCI_RESP|MCI_ARG, &response))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -553,14 +550,13 @@ static int sd_wait_for_state(const int drive, unsigned int state)
|
||||||
if (((response >> 9) & 0xf) == state)
|
if (((response >> 9) & 0xf) == state)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(TIME_AFTER(current_tick, t + timeout))
|
if(TIME_AFTER(current_tick, timeout))
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
if (TIME_AFTER((tick = current_tick), next_yield))
|
if (TIME_AFTER(current_tick, next_yield))
|
||||||
{
|
{
|
||||||
yield();
|
yield();
|
||||||
timeout += current_tick - tick;
|
next_yield = current_tick + MIN_YIELD_PERIOD;
|
||||||
next_yield = tick + MIN_YIELD_PERIOD;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue