summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-12-06 15:17:30 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-12-06 15:17:30 +0000
commitefd90770a01abc3cc4f4d875e194f560be6ed7db (patch)
tree5d71e99851046d76492c9d7341e63428b4523f2d
parentbd0da0e822e4f15d1234ae63a94131a77d3414a0 (diff)
downloadrockbox-efd90770a01abc3cc4f4d875e194f560be6ed7db.tar.gz
rockbox-efd90770a01abc3cc4f4d875e194f560be6ed7db.zip
Bug fix: Don't cut the power during spinup...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2959 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/ata.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 9e67ea4cce..79193d9800 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -81,6 +81,7 @@ static volatile unsigned char* ata_control;
bool old_recorder = false;
int ata_spinup_time = 0;
+static bool spinup = false;
static bool sleeping = false;
static int sleep_timeout = 5*HZ;
static bool poweroff = false;
@@ -165,7 +166,6 @@ int ata_read_sectors(unsigned long start,
int timeout;
int count;
void* buf;
- bool spinup = false;
mutex_lock(&ata_mtx);
@@ -174,6 +174,7 @@ int ata_read_sectors(unsigned long start,
led(true);
if ( sleeping ) {
+ spinup = true;
if (poweroff) {
if (ata_power_on()) {
mutex_unlock(&ata_mtx);
@@ -186,7 +187,6 @@ int ata_read_sectors(unsigned long start,
return -1;
}
}
- spinup = true;
}
ATA_SELECT = ata_device;
@@ -292,7 +292,6 @@ int ata_write_sectors(unsigned long start,
{
int i;
int ret = 0;
- bool spinup = false;
if (start == 0)
panicf("Writing on sector 0\n");
@@ -302,6 +301,7 @@ int ata_write_sectors(unsigned long start,
last_disk_activity = current_tick;
if ( sleeping ) {
+ spinup = true;
if (poweroff) {
if (ata_power_on()) {
mutex_unlock(&ata_mtx);
@@ -314,7 +314,6 @@ int ata_write_sectors(unsigned long start,
return -1;
}
}
- spinup = true;
}
ATA_SELECT = ata_device;
@@ -493,8 +492,7 @@ static void ata_thread(void)
while (1) {
while ( queue_empty( &ata_queue ) ) {
- if ( sleep_timeout &&
- !sleeping &&
+ if ( !spinup && sleep_timeout && !sleeping &&
TIME_AFTER( current_tick,
last_user_activity + sleep_timeout ) &&
TIME_AFTER( current_tick,
@@ -505,7 +503,7 @@ static void ata_thread(void)
}
#ifdef HAVE_ATA_POWER_OFF
- if ( sleeping && poweroff_timeout && !poweroff &&
+ if ( !spinup && sleeping && poweroff_timeout && !poweroff &&
TIME_AFTER( current_tick, last_sleep + poweroff_timeout ))
{
mutex_lock(&ata_mtx);