diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2010-05-27 23:32:29 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2010-05-27 23:32:29 +0000 |
commit | 9ff986cdca896cc3ea7f8b2b46806b508f849c34 (patch) | |
tree | 02d9df856e3fb7b37e5a85eaf16f38a30a443a50 | |
parent | 6b6123444e5f1e75eb6167e8f061164f57408f66 (diff) | |
download | rockbox-9ff986cdca896cc3ea7f8b2b46806b508f849c34.tar.gz rockbox-9ff986cdca896cc3ea7f8b2b46806b508f849c34.zip |
sd-as3525v2: Include time spent yielding when figuring timeout in sd_wait_for_tran_state()
(apply r23738 to as3525v2 code)
extend the arbitrary delay to 5 seconds, we never know
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26342 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/arm/as3525/sd-as3525v2.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c index 061be8d1c2..2d796c63cb 100644 --- a/firmware/target/arm/as3525/sd-as3525v2.c +++ b/firmware/target/arm/as3525/sd-as3525v2.c | |||
@@ -759,26 +759,22 @@ int sd_init(void) | |||
759 | static int sd_wait_for_tran_state(const int drive) | 759 | static int sd_wait_for_tran_state(const int drive) |
760 | { | 760 | { |
761 | unsigned long response; | 761 | unsigned long response; |
762 | unsigned int timeout = 100; /* ticks */ | 762 | unsigned int timeout = current_tick + 5*HZ; |
763 | long t = current_tick; | ||
764 | 763 | ||
765 | while (1) | 764 | while (1) |
766 | { | 765 | { |
767 | long tick; | ||
768 | |||
769 | while(!(send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, MCI_RESP, &response))); | 766 | while(!(send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, MCI_RESP, &response))); |
770 | 767 | ||
771 | if (((response >> 9) & 0xf) == SD_TRAN) | 768 | if (((response >> 9) & 0xf) == SD_TRAN) |
772 | return 0; | 769 | return 0; |
773 | 770 | ||
774 | if(TIME_AFTER(current_tick, t + timeout)) | 771 | if(TIME_AFTER(current_tick, timeout)) |
775 | return -10 * ((response >> 9) & 0xf); | 772 | return -10 * ((response >> 9) & 0xf); |
776 | 773 | ||
777 | if (TIME_AFTER((tick = current_tick), next_yield)) | 774 | if (TIME_AFTER(current_tick, next_yield)) |
778 | { | 775 | { |
779 | yield(); | 776 | yield(); |
780 | timeout += current_tick - tick; | 777 | next_yield = current_tick + MIN_YIELD_PERIOD; |
781 | next_yield = tick + MIN_YIELD_PERIOD; | ||
782 | } | 778 | } |
783 | } | 779 | } |
784 | } | 780 | } |