From 3b36b98ff8dea187bd6c25174978da4f7b5e3231 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 18 Jan 2008 12:32:03 +0000 Subject: Properly serialize ata_init with other threads. Fix a bug that always initialized the lock on every call to ata_init - that should be a one time init or else the lock could be corrupted on connect. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16104 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/sandisk/ata-c200_e200.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/sandisk/ata-c200_e200.c b/firmware/target/arm/sandisk/ata-c200_e200.c index 5a7577f08d..ef2bad387b 100644 --- a/firmware/target/arm/sandisk/ata-c200_e200.c +++ b/firmware/target/arm/sandisk/ata-c200_e200.c @@ -1149,17 +1149,17 @@ int ata_init(void) { int ret = 0; + if (!initialized) + spinlock_init(&sd_spin IF_COP(, SPINLOCK_TASK_SWITCH)); + + spinlock_lock(&sd_spin); + ata_led(false); - /* NOTE: This init isn't dual core safe */ if (!initialized) { initialized = true; - spinlock_init(&sd_spin IF_COP(, SPINLOCK_TASK_SWITCH)); - - spinlock_lock(&sd_spin); - /* init controller */ outl(inl(0x70000088) & ~(0x4), 0x70000088); outl(inl(0x7000008c) & ~(0x4), 0x7000008c); @@ -1213,9 +1213,10 @@ int ata_init(void) GPIOL_INT_EN |= 0x08; #endif #endif - spinlock_unlock(&sd_spin); } + spinlock_unlock(&sd_spin); + return ret; } -- cgit v1.2.3