diff options
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c index d2438655e2..116d9849cc 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | |||
@@ -1184,13 +1184,11 @@ static int sd_select_card(void) | |||
1184 | return 0; | 1184 | return 0; |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | static int sd_init_device(void) | 1187 | static int __sd_init_device(void) |
1188 | { | 1188 | { |
1189 | int retval; | 1189 | int retval; |
1190 | struct sd_request init_req; | 1190 | struct sd_request init_req; |
1191 | 1191 | ||
1192 | mutex_lock(&sd_mtx); | ||
1193 | |||
1194 | /* Initialise card data as blank */ | 1192 | /* Initialise card data as blank */ |
1195 | memset(&card, 0, sizeof(tCardInfo)); | 1193 | memset(&card, 0, sizeof(tCardInfo)); |
1196 | 1194 | ||
@@ -1210,7 +1208,6 @@ static int sd_init_device(void) | |||
1210 | retval = (retval == SD_INIT_PASSED ? sd_select_card() : -1); | 1208 | retval = (retval == SD_INIT_PASSED ? sd_select_card() : -1); |
1211 | 1209 | ||
1212 | __cpm_stop_msc(); /* disable SD clock */ | 1210 | __cpm_stop_msc(); /* disable SD clock */ |
1213 | mutex_unlock(&sd_mtx); | ||
1214 | 1211 | ||
1215 | return retval; | 1212 | return retval; |
1216 | } | 1213 | } |
@@ -1225,7 +1222,11 @@ int sd_init(void) | |||
1225 | inited = true; | 1222 | inited = true; |
1226 | } | 1223 | } |
1227 | 1224 | ||
1228 | return sd_init_device(); | 1225 | mutex_lock(&sd_mtx); |
1226 | int ret = __sd_init_device(); | ||
1227 | mutex_unlock(&sd_mtx); | ||
1228 | |||
1229 | return ret; | ||
1229 | } | 1230 | } |
1230 | 1231 | ||
1231 | static inline bool card_detect_target(void) | 1232 | static inline bool card_detect_target(void) |
@@ -1267,7 +1268,7 @@ int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf) | |||
1267 | if (!card_detect_target() || count == 0 || start > card.numblocks) | 1268 | if (!card_detect_target() || count == 0 || start > card.numblocks) |
1268 | goto err; | 1269 | goto err; |
1269 | 1270 | ||
1270 | if(card.initialized == 0 && !sd_init_device()) | 1271 | if(card.initialized == 0 && !__sd_init_device()) |
1271 | goto err; | 1272 | goto err; |
1272 | 1273 | ||
1273 | sd_simple_cmd(&request, SD_SEND_STATUS, card.rca, RESPONSE_R1); | 1274 | sd_simple_cmd(&request, SD_SEND_STATUS, card.rca, RESPONSE_R1); |
@@ -1321,7 +1322,7 @@ int sd_write_sectors(IF_MV(int drive,) unsigned long start, int count, const voi | |||
1321 | if (!card_detect_target() || count == 0 || start > card.numblocks) | 1322 | if (!card_detect_target() || count == 0 || start > card.numblocks) |
1322 | goto err; | 1323 | goto err; |
1323 | 1324 | ||
1324 | if(card.initialized == 0 && !sd_init_device()) | 1325 | if(card.initialized == 0 && !__sd_init_device()) |
1325 | goto err; | 1326 | goto err; |
1326 | 1327 | ||
1327 | sd_simple_cmd(&request, SD_SEND_STATUS, card.rca, RESPONSE_R1); | 1328 | sd_simple_cmd(&request, SD_SEND_STATUS, card.rca, RESPONSE_R1); |