diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-07-10 15:32:02 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-07-10 15:32:02 +0000 |
commit | e7f0c3f39770fbc183d729a1d76f0bebbbc77d2a (patch) | |
tree | f1a42cd43a6b6e79a4361b5d243ee9083ccd71bb /firmware/target | |
parent | edfcc10876472e616a241393a4b4c5bbdb7b7aba (diff) |
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
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/as3525/ata_sd_as3525.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c index 2766c76e41..c2a621d665 100644 --- a/firmware/target/arm/as3525/ata_sd_as3525.c +++ b/firmware/target/arm/as3525/ata_sd_as3525.c @@ -344,9 +344,6 @@ static void sd_thread(void) { struct queue_event ev; bool idle_notified = false; -#ifdef HAVE_HOTSWAP - int microsd_init; -#endif while (1) { @@ -357,6 +354,8 @@ static void sd_thread(void) #ifdef HAVE_HOTSWAP case SYS_HOTSWAP_INSERTED: case SYS_HOTSWAP_EXTRACTED: + { + int microsd_init = 1; fat_lock(); /* lock-out FAT activity first - prevent deadlocking via disk_mount that would cause a reverse-order attempt with @@ -379,25 +378,23 @@ static void sd_thread(void) sd_enable(true); init_pl180_controller(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); - if (!disk_mount(SD_SLOT_AS3525)) /* mount failed */ - { - /* Access is now safe */ - mutex_unlock(&sd_mtx); - fat_unlock(); - sd_enable(false); - break; - } + microsd_init = disk_mount(SD_SLOT_AS3525); /* 0 if fail */ } - queue_broadcast(SYS_FS_CHANGED, 0); + /* + * 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); /* Access is now safe */ mutex_unlock(&sd_mtx); fat_unlock(); sd_enable(false); + } break; #endif case SYS_TIMEOUT: |