summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorTobias Diedrich <ranma+coreboot@tdiedrich.de>2010-06-29 19:12:57 +0000
committerTobias Diedrich <ranma+coreboot@tdiedrich.de>2010-06-29 19:12:57 +0000
commit23cf76c2af5ff77255a617da20002a61bae1eed8 (patch)
tree376168eb17840b9464864bd3a022fa09dde7dfb9 /firmware
parentcdf27ae12120cb67467346a90912cb623d24a894 (diff)
downloadrockbox-23cf76c2af5ff77255a617da20002a61bae1eed8.tar.gz
rockbox-23cf76c2af5ff77255a617da20002a61bae1eed8.tar.bz2
rockbox-23cf76c2af5ff77255a617da20002a61bae1eed8.zip
mutex_lock/unlock must be moved up a level to make the verify code in sd-as3525.c safe
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27180 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/sd-as3525.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index 1fd10bfaee..40392b35b2 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -689,7 +689,6 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
unsigned long response;
bool aligned = !((uintptr_t)buf & (CACHEALIGN_SIZE - 1));
- mutex_lock(&sd_mtx);
sd_enable(true);
led(true);
@@ -870,14 +869,19 @@ sd_transfer_error_nodma:
if (ret) /* error */
card_info[drive].initialized = 0;
- mutex_unlock(&sd_mtx);
return ret;
}
int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
void* buf)
{
- return sd_transfer_sectors(IF_MD2(drive,) start, count, buf, false);
+ int ret;
+
+ mutex_lock(&sd_mtx);
+ ret = sd_transfer_sectors(IF_MD2(drive,) start, count, buf, false);
+ mutex_unlock(&sd_mtx);
+
+ return ret;
}
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
@@ -890,11 +894,13 @@ int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
#endif
int ret;
+ mutex_lock(&sd_mtx);
+
ret = sd_transfer_sectors(IF_MD2(drive,) start, count, (void*)buf, true);
#ifdef VERIFY_WRITE
if (ret) /* write failed, no point in verifying */
- return ret;
+ goto write_error;
count = saved_count;
buf = saved_buf;
@@ -916,6 +922,10 @@ int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
start += transfer;
}
#endif
+
+write_error:
+ mutex_unlock(&sd_mtx);
+
return ret;
}