From bd0da0e822e4f15d1234ae63a94131a77d3414a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Stenberg?= Date: Fri, 6 Dec 2002 13:08:42 +0000 Subject: [PATCH] Fixed a race condition between sleep thread and spinup code. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2958 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 9b092e1402..9e67ea4cce 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -186,8 +186,6 @@ int ata_read_sectors(unsigned long start, return -1; } } - sleeping = false; - poweroff = false; spinup = true; } @@ -226,16 +224,18 @@ int ata_read_sectors(unsigned long start, goto retry; } - if (spinup) { - ata_spinup_time = current_tick - last_disk_activity; - spinup = false; - } - if ( ATA_ALT_STATUS & (STATUS_ERR | STATUS_DF) ) { ret = -5; goto retry; } + if (spinup) { + ata_spinup_time = current_tick - last_disk_activity; + spinup = false; + sleeping = false; + poweroff = false; + } + /* if destination address is odd, use byte copying, otherwise use word copying */ @@ -314,8 +314,6 @@ int ata_write_sectors(unsigned long start, return -1; } } - sleeping = false; - poweroff = false; spinup = true; } @@ -349,6 +347,8 @@ int ata_write_sectors(unsigned long start, if (spinup) { ata_spinup_time = current_tick - last_disk_activity; spinup = false; + sleeping = false; + poweroff = false; } for (j=0; j