summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pp/ata-sd-pp.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pp/ata-sd-pp.c')
-rw-r--r--firmware/target/arm/pp/ata-sd-pp.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/firmware/target/arm/pp/ata-sd-pp.c b/firmware/target/arm/pp/ata-sd-pp.c
index bcf8a660c2..2a11b40fee 100644
--- a/firmware/target/arm/pp/ata-sd-pp.c
+++ b/firmware/target/arm/pp/ata-sd-pp.c
@@ -19,7 +19,6 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include "config.h" /* for HAVE_MULTIDRIVE */ 21#include "config.h" /* for HAVE_MULTIDRIVE */
22#include "fat.h"
23#include "sdmmc.h" 22#include "sdmmc.h"
24#include "gcc_extensions.h" 23#include "gcc_extensions.h"
25#ifdef HAVE_HOTSWAP 24#ifdef HAVE_HOTSWAP
@@ -1125,35 +1124,28 @@ static void sd_thread(void)
1125 { 1124 {
1126#ifdef HAVE_HOTSWAP 1125#ifdef HAVE_HOTSWAP
1127 case SYS_HOTSWAP_INSERTED: 1126 case SYS_HOTSWAP_INSERTED:
1128 case SYS_HOTSWAP_EXTRACTED: 1127 case SYS_HOTSWAP_EXTRACTED:;
1129 fat_lock(); /* lock-out FAT activity first - 1128 int success = 1;
1130 prevent deadlocking via disk_mount that
1131 would cause a reverse-order attempt with
1132 another thread */
1133 mutex_lock(&sd_mtx); /* lock-out card activity - direct calls
1134 into driver that bypass the fat cache */
1135 1129
1136 /* We now have exclusive control of fat cache and ata */ 1130 disk_unmount(sd_first_drive+1); /* release "by force" */
1137 1131
1138 disk_unmount(sd_first_drive+1); /* release "by force", ensure file 1132 mutex_lock(&sd_mtx); /* lock-out card activity */
1139 descriptors aren't leaked and any busy
1140 ones are invalid if mounting */
1141 1133
1142 /* Force card init for new card, re-init for re-inserted one or 1134 /* Force card init for new card, re-init for re-inserted one or
1143 * clear if the last attempt to init failed with an error. */ 1135 * clear if the last attempt to init failed with an error. */
1144 card_info[1].initialized = 0; 1136 card_info[1].initialized = 0;
1145 sd_status[1].retry = 0; 1137 sd_status[1].retry = 0;
1146 1138
1147 if (ev.id == SYS_HOTSWAP_INSERTED)
1148 disk_mount(sd_first_drive+1);
1149
1150 queue_broadcast(SYS_FS_CHANGED, 0);
1151
1152 /* Access is now safe */ 1139 /* Access is now safe */
1153 mutex_unlock(&sd_mtx); 1140 mutex_unlock(&sd_mtx);
1154 fat_unlock(); 1141
1142 if (ev.id == SYS_HOTSWAP_INSERTED)
1143 success = disk_mount(sd_first_drive+1); /* 0 if fail */
1144
1145 if (success)
1146 queue_broadcast(SYS_FS_CHANGED, 0);
1155 break; 1147 break;
1156#endif 1148#endif /* HAVE_HOTSWAP */
1157 case SYS_TIMEOUT: 1149 case SYS_TIMEOUT:
1158 if (TIME_BEFORE(current_tick, last_disk_activity+(3*HZ))) 1150 if (TIME_BEFORE(current_tick, last_disk_activity+(3*HZ)))
1159 { 1151 {