summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-08-29 11:50:57 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-08-29 11:50:57 +0000
commit5d154f9723f2805f73d6d32233f534582618f1a7 (patch)
tree39359de1542f7cc46677ebe88fd718b523d778bf /firmware
parent53ee298d4a68affe028d508c260f619bb04e992d (diff)
wait_for_rdy() now actually waits for RDY
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2057 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/ata.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 584c8549e6..1a8ff37cb7 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -122,9 +122,25 @@ static int wait_for_bsy(void)
static int wait_for_rdy(void) __attribute__ ((section (".icode")));
static int wait_for_rdy(void)
{
+ int timeout;
+
if (!wait_for_bsy())
return 0;
- return ATA_ALT_STATUS & STATUS_RDY;
+
+ timeout = current_tick + HZ*4;
+
+ while (TIME_BEFORE(current_tick, timeout) &&
+ !(ATA_ALT_STATUS & STATUS_RDY))
+ yield();
+
+ if (TIME_BEFORE(current_tick, timeout))
+ {
+ return STATUS_RDY;
+ }
+ else
+ {
+ return 0; /* timeout */
+ }
}
static int wait_for_start_of_transfer(void) __attribute__ ((section (".icode")));