Rearrange things a bit for less #ifdefs and less duplication.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21744 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2009-07-10 15:32:02 +00:00
parent edfcc10876
commit e7f0c3f397

View file

@ -344,9 +344,6 @@ static void sd_thread(void)
{ {
struct queue_event ev; struct queue_event ev;
bool idle_notified = false; bool idle_notified = false;
#ifdef HAVE_HOTSWAP
int microsd_init;
#endif
while (1) while (1)
{ {
@ -357,6 +354,8 @@ static void sd_thread(void)
#ifdef HAVE_HOTSWAP #ifdef HAVE_HOTSWAP
case SYS_HOTSWAP_INSERTED: case SYS_HOTSWAP_INSERTED:
case SYS_HOTSWAP_EXTRACTED: case SYS_HOTSWAP_EXTRACTED:
{
int microsd_init = 1;
fat_lock(); /* lock-out FAT activity first - fat_lock(); /* lock-out FAT activity first -
prevent deadlocking via disk_mount that prevent deadlocking via disk_mount that
would cause a reverse-order attempt with would cause a reverse-order attempt with
@ -379,25 +378,23 @@ static void sd_thread(void)
sd_enable(true); sd_enable(true);
init_pl180_controller(SD_SLOT_AS3525); init_pl180_controller(SD_SLOT_AS3525);
microsd_init = sd_init_card(SD_SLOT_AS3525); microsd_init = sd_init_card(SD_SLOT_AS3525);
if (microsd_init < 0) if (microsd_init < 0) /* initialisation failed */
panicf("microSD init failed : %d", microsd_init); panicf("microSD init failed : %d", microsd_init);
if (!disk_mount(SD_SLOT_AS3525)) /* mount failed */ microsd_init = disk_mount(SD_SLOT_AS3525); /* 0 if fail */
{
/* Access is now safe */
mutex_unlock(&sd_mtx);
fat_unlock();
sd_enable(false);
break;
}
} }
/*
* Mount succeeded, or this was an EXTRACTED event,
* in both cases notify the system about the additional filesystem
if (microsd_init)
queue_broadcast(SYS_FS_CHANGED, 0); queue_broadcast(SYS_FS_CHANGED, 0);
/* Access is now safe */ /* Access is now safe */
mutex_unlock(&sd_mtx); mutex_unlock(&sd_mtx);
fat_unlock(); fat_unlock();
sd_enable(false); sd_enable(false);
}
break; break;
#endif #endif
case SYS_TIMEOUT: case SYS_TIMEOUT: