From 9e93b9e30a524f7ca787b1198d572a9f36da080e Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 20 Jan 2008 12:44:13 +0000 Subject: [PATCH] Proper mutexing in the MMC driver's ata_init(), resembling what is done in the ata driver. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16116 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata_mmc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 604d1dde34..6d69501deb 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c @@ -1117,8 +1117,12 @@ int ata_init(void) { int rc = 0; - mutex_init(&mmc_mutex); - + if (!initialized) + { + mutex_init(&mmc_mutex); + queue_init(&mmc_queue, true); + } + mutex_lock(&mmc_mutex); led(false); /* Port setup */ @@ -1151,7 +1155,6 @@ int ata_init(void) if (!last_mmc_status) mmc_status = MMC_UNTOUCHED; - queue_init(&mmc_queue, true); create_thread(mmc_thread, mmc_stack, sizeof(mmc_stack), 0, mmc_thread_name IF_PRIO(, PRIORITY_SYSTEM) @@ -1160,6 +1163,7 @@ int ata_init(void) initialized = true; } + mutex_unlock(&mmc_mutex); return rc; }