summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-03-13 15:45:38 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-03-13 15:45:38 +0000
commitb12401b4d4fd4a145db8cd2abcac253bb0e50fea (patch)
tree270528ad606a53a9151f31987e4bcc206ecf2abc /firmware
parent1609d6b486c920747686eca36f97db56176a5176 (diff)
downloadrockbox-b12401b4d4fd4a145db8cd2abcac253bb0e50fea.tar.gz
rockbox-b12401b4d4fd4a145db8cd2abcac253bb0e50fea.zip
Initialize return code at start of loop, not at the end.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3440 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/ata.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index c2a02cb03c..523b080ec8 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -204,6 +204,7 @@ int ata_read_sectors(unsigned long start,
buf = inbuf;
count = incount;
while (TIME_BEFORE(current_tick, timeout)) {
+ ret = 0;
if ( count == 256 )
ATA_NSECTOR = 0; /* 0 means 256 sectors */
@@ -276,15 +277,14 @@ int ata_read_sectors(unsigned long start,
ret = -3;
goto retry;
}
-
- ret = 0;
break;
}
led(false);
mutex_unlock(&ata_mtx);
- if ( delayed_write )
+ /* only flush if reading went ok */
+ if ( (ret == 0) && delayed_write )
ata_flush();
return ret;
@@ -373,7 +373,8 @@ int ata_write_sectors(unsigned long start,
mutex_unlock(&ata_mtx);
- if ( delayed_write )
+ /* only flush if writing went ok */
+ if ( (ret == 0) && delayed_write )
ata_flush();
return ret;