msm: sdio_cmux: Deinit the channel variables in proper sequence

When the logical channel is closed, de-init the channel variables in
proper sequence while holding appropriate locks. This will avoid race
condition between channel close and any channel events.

Change-Id: Ib0c53380a909c0737ff3f4a9eee1b2accbf2d2e6
CRs-Fixed: 312930
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
diff --git a/arch/arm/mach-msm/sdio_cmux.c b/arch/arm/mach-msm/sdio_cmux.c
index f7c25c3..0aa5423 100644
--- a/arch/arm/mach-msm/sdio_cmux.c
+++ b/arch/arm/mach-msm/sdio_cmux.c
@@ -336,10 +336,12 @@
 
 	ch = &logical_ch[id];
 	mutex_lock(&ch->lc_lock);
+	ch->receive_cb = NULL;
+	mutex_lock(&ch->tx_lock);
+	ch->write_done = NULL;
+	mutex_unlock(&ch->tx_lock);
 	ch->is_local_open = 0;
 	ch->priv = NULL;
-	ch->receive_cb = NULL;
-	ch->write_done = NULL;
 	mutex_unlock(&ch->lc_lock);
 	sdio_cmux_write_cmd(ch->lc_id, CLOSE);
 	return 0;