diff options
Diffstat (limited to 'firmware/target/arm')
-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) | |||
344 | { | 344 | { |
345 | struct queue_event ev; | 345 | struct queue_event ev; |
346 | bool idle_notified = false; | 346 | bool idle_notified = false; |
347 | #ifdef HAVE_HOTSWAP | ||
348 | int microsd_init; | ||
349 | #endif | ||
350 | 347 | ||
351 | while (1) | 348 | while (1) |
352 | { | 349 | { |
@@ -357,6 +354,8 @@ static void sd_thread(void) | |||
357 | #ifdef HAVE_HOTSWAP | 354 | #ifdef HAVE_HOTSWAP |
358 | case SYS_HOTSWAP_INSERTED: | 355 | case SYS_HOTSWAP_INSERTED: |
359 | case SYS_HOTSWAP_EXTRACTED: | 356 | case SYS_HOTSWAP_EXTRACTED: |
357 | { | ||
358 | int microsd_init = 1; | ||
360 | fat_lock(); /* lock-out FAT activity first - | 359 | fat_lock(); /* lock-out FAT activity first - |
361 | prevent deadlocking via disk_mount that | 360 | prevent deadlocking via disk_mount that |
362 | would cause a reverse-order attempt with | 361 | would cause a reverse-order attempt with |
@@ -379,25 +378,23 @@ static void sd_thread(void) | |||
379 | sd_enable(true); | 378 | sd_enable(true); |
380 | init_pl180_controller(SD_SLOT_AS3525); | 379 | init_pl180_controller(SD_SLOT_AS3525); |
381 | microsd_init = sd_init_card(SD_SLOT_AS3525); | 380 | microsd_init = sd_init_card(SD_SLOT_AS3525); |
382 | if (microsd_init < 0) | 381 | if (microsd_init < 0) /* initialisation failed */ |
383 | panicf("microSD init failed : %d", microsd_init); | 382 | panicf("microSD init failed : %d", microsd_init); |
384 | 383 | ||
385 | if (!disk_mount(SD_SLOT_AS3525)) /* mount failed */ | 384 | microsd_init = disk_mount(SD_SLOT_AS3525); /* 0 if fail */ |
386 | { | ||
387 | /* Access is now safe */ | ||
388 | mutex_unlock(&sd_mtx); | ||
389 | fat_unlock(); | ||
390 | sd_enable(false); | ||
391 | break; | ||
392 | } | ||
393 | } | 385 | } |
394 | 386 | ||
395 | queue_broadcast(SYS_FS_CHANGED, 0); | 387 | /* |
388 | * Mount succeeded, or this was an EXTRACTED event, | ||
389 | * in both cases notify the system about the additional filesystem | ||
390 | if (microsd_init) | ||
391 | queue_broadcast(SYS_FS_CHANGED, 0); | ||
396 | 392 | ||
397 | /* Access is now safe */ | 393 | /* Access is now safe */ |
398 | mutex_unlock(&sd_mtx); | 394 | mutex_unlock(&sd_mtx); |
399 | fat_unlock(); | 395 | fat_unlock(); |
400 | sd_enable(false); | 396 | sd_enable(false); |
397 | } | ||
401 | break; | 398 | break; |
402 | #endif | 399 | #endif |
403 | case SYS_TIMEOUT: | 400 | case SYS_TIMEOUT: |