diff options
Diffstat (limited to 'firmware/target/arm/s3c2440')
-rw-r--r-- | firmware/target/arm/s3c2440/sd-s3c2440.c | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/firmware/target/arm/s3c2440/sd-s3c2440.c b/firmware/target/arm/s3c2440/sd-s3c2440.c index 6658fa1515..e8de3ac78d 100644 --- a/firmware/target/arm/s3c2440/sd-s3c2440.c +++ b/firmware/target/arm/s3c2440/sd-s3c2440.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #ifdef HAVE_HOTSWAP | 34 | #ifdef HAVE_HOTSWAP |
35 | #include "sdmmc.h" | 35 | #include "sdmmc.h" |
36 | #include "disk.h" | 36 | #include "disk.h" |
37 | #include "fat.h" | ||
38 | #endif | 37 | #endif |
39 | #include "dma-target.h" | 38 | #include "dma-target.h" |
40 | #include "system-target.h" | 39 | #include "system-target.h" |
@@ -585,48 +584,29 @@ static void sd_thread(void) | |||
585 | { | 584 | { |
586 | #ifdef HAVE_HOTSWAP | 585 | #ifdef HAVE_HOTSWAP |
587 | case SYS_HOTSWAP_INSERTED: | 586 | case SYS_HOTSWAP_INSERTED: |
588 | case SYS_HOTSWAP_EXTRACTED: | 587 | case SYS_HOTSWAP_EXTRACTED:; |
589 | { | ||
590 | int success = 1; | 588 | int success = 1; |
591 | fat_lock(); /* lock-out FAT activity first - | ||
592 | prevent deadlocking via disk_mount that | ||
593 | would cause a reverse-order attempt with | ||
594 | another thread */ | ||
595 | mutex_lock(&sd_mtx); /* lock-out card activity - direct calls | ||
596 | into driver that bypass the fat cache */ | ||
597 | 589 | ||
598 | /* We now have exclusive control of fat cache and ata */ | 590 | disk_unmount(0); /* release "by force" */ |
599 | 591 | ||
600 | disk_unmount(0); /* release "by force", ensure file | 592 | mutex_lock(&sd_mtx); /* lock-out card activity */ |
601 | descriptors aren't leaked and any busy | ||
602 | ones are invalid if mounting */ | ||
603 | 593 | ||
604 | /* Force card init for new card, re-init for re-inserted one or | 594 | /* Force card init for new card, re-init for re-inserted one or |
605 | * clear if the last attempt to init failed with an error. */ | 595 | * clear if the last attempt to init failed with an error. */ |
606 | card_info[0].initialized = 0; | 596 | card_info[0].initialized = 0; |
607 | 597 | ||
598 | /* Access is now safe */ | ||
599 | mutex_unlock(&sd_mtx); | ||
600 | |||
608 | if (ev.id == SYS_HOTSWAP_INSERTED) | 601 | if (ev.id == SYS_HOTSWAP_INSERTED) |
609 | { | ||
610 | /* FIXME: once sd_enabled is implement properly, | ||
611 | * reinitializing the controllers might be needed */ | ||
612 | sd_enable(true); | ||
613 | if (success < 0) /* initialisation failed */ | ||
614 | panicf("SD init failed : %d", success); | ||
615 | success = disk_mount(0); /* 0 if fail */ | 602 | success = disk_mount(0); /* 0 if fail */ |
616 | } | ||
617 | 603 | ||
618 | /* notify the system about the changed filesystems | 604 | /* notify the system about the changed filesystems |
619 | */ | 605 | */ |
620 | if (success) | 606 | if (success) |
621 | queue_broadcast(SYS_FS_CHANGED, 0); | 607 | queue_broadcast(SYS_FS_CHANGED, 0); |
622 | |||
623 | /* Access is now safe */ | ||
624 | mutex_unlock(&sd_mtx); | ||
625 | fat_unlock(); | ||
626 | sd_enable(false); | ||
627 | } | ||
628 | break; | 608 | break; |
629 | #endif | 609 | #endif /* HAVE_HOTSWAP */ |
630 | } | 610 | } |
631 | } | 611 | } |
632 | } | 612 | } |