diff options
Diffstat (limited to 'firmware/target/arm/as3525/ata_sd_as3525.c')
-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 9f2514d8ba..e71c886021 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)) | |||
539 | static int sd_wait_for_state(const int drive, unsigned int state) | 539 | static int sd_wait_for_state(const int drive, unsigned int state) |
540 | { | 540 | { |
541 | unsigned long response = 0; | 541 | unsigned long response = 0; |
542 | unsigned int timeout = 100; /* ticks */ | 542 | unsigned int timeout = current_tick + 100; /* 100 ticks timeout */ |
543 | long t = current_tick; | ||
544 | 543 | ||
545 | while (1) | 544 | while (1) |
546 | { | 545 | { |
547 | long tick; | ||
548 | |||
549 | if(!send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, | 546 | if(!send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, |
550 | MCI_RESP|MCI_ARG, &response)) | 547 | MCI_RESP|MCI_ARG, &response)) |
551 | return -1; | 548 | return -1; |
@@ -553,14 +550,13 @@ static int sd_wait_for_state(const int drive, unsigned int state) | |||
553 | if (((response >> 9) & 0xf) == state) | 550 | if (((response >> 9) & 0xf) == state) |
554 | return 0; | 551 | return 0; |
555 | 552 | ||
556 | if(TIME_AFTER(current_tick, t + timeout)) | 553 | if(TIME_AFTER(current_tick, timeout)) |
557 | return -2; | 554 | return -2; |
558 | 555 | ||
559 | if (TIME_AFTER((tick = current_tick), next_yield)) | 556 | if (TIME_AFTER(current_tick, next_yield)) |
560 | { | 557 | { |
561 | yield(); | 558 | yield(); |
562 | timeout += current_tick - tick; | 559 | next_yield = current_tick + MIN_YIELD_PERIOD; |
563 | next_yield = tick + MIN_YIELD_PERIOD; | ||
564 | } | 560 | } |
565 | } | 561 | } |
566 | } | 562 | } |