summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/sdmmc-dm320.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tms320dm320/sdmmc-dm320.c')
-rw-r--r--firmware/target/arm/tms320dm320/sdmmc-dm320.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/firmware/target/arm/tms320dm320/sdmmc-dm320.c b/firmware/target/arm/tms320dm320/sdmmc-dm320.c
index 284061e1ad..d46dbf5e40 100644
--- a/firmware/target/arm/tms320dm320/sdmmc-dm320.c
+++ b/firmware/target/arm/tms320dm320/sdmmc-dm320.c
@@ -592,48 +592,29 @@ static void sd_thread(void)
592 { 592 {
593#ifdef HAVE_HOTSWAP 593#ifdef HAVE_HOTSWAP
594 case SYS_HOTSWAP_INSERTED: 594 case SYS_HOTSWAP_INSERTED:
595 case SYS_HOTSWAP_EXTRACTED: 595 case SYS_HOTSWAP_EXTRACTED:;
596 {
597 int success = 1; 596 int success = 1;
598 fat_lock(); /* lock-out FAT activity first -
599 prevent deadlocking via disk_mount that
600 would cause a reverse-order attempt with
601 another thread */
602 mutex_lock(&sd_mtx); /* lock-out card activity - direct calls
603 into driver that bypass the fat cache */
604 597
605 /* We now have exclusive control of fat cache and ata */ 598 disk_unmount(0); /* release "by force" */
606 599
607 disk_unmount(0); /* release "by force", ensure file 600 mutex_lock(&sd_mtx); /* lock-out card activity */
608 descriptors aren't leaked and any busy
609 ones are invalid if mounting */
610 601
611 /* Force card init for new card, re-init for re-inserted one or 602 /* Force card init for new card, re-init for re-inserted one or
612 * clear if the last attempt to init failed with an error. */ 603 * clear if the last attempt to init failed with an error. */
613 card_info[0].initialized = 0; 604 card_info[0].initialized = 0;
614 605
606 mutex_unlock(&sd_mtx);
607
615 if (ev.id == SYS_HOTSWAP_INSERTED) 608 if (ev.id == SYS_HOTSWAP_INSERTED)
616 {
617 /* FIXME: once sd_enabled is implement properly,
618 * reinitializing the controllers might be needed */
619 sd_enable(true);
620 if (success < 0) /* initialisation failed */
621 panicf("SD init failed : %d", success);
622 success = disk_mount(0); /* 0 if fail */ 609 success = disk_mount(0); /* 0 if fail */
623 }
624 610
625 /* notify the system about the changed filesystems 611 /* notify the system about the changed filesystems */
626 */
627 if (success) 612 if (success)
628 queue_broadcast(SYS_FS_CHANGED, 0); 613 queue_broadcast(SYS_FS_CHANGED, 0);
629 614
630 /* Access is now safe */
631 mutex_unlock(&sd_mtx);
632 fat_unlock();
633 sd_enable(false);
634 }
635 break; 615 break;
636#endif 616#endif /* HAVE_HOTSWAP */
617
637 case SYS_TIMEOUT: 618 case SYS_TIMEOUT:
638 if (TIME_BEFORE(current_tick, last_disk_activity+(3*HZ))) 619 if (TIME_BEFORE(current_tick, last_disk_activity+(3*HZ)))
639 { 620 {