msm: sdio: adding multi channel and multi device test for LPM

The testing mechanism and correctness checking had to be changed
in order to support multi channels and multi devices LPM test.
To support that, all the LPM info must be configured and saved per device,
while each device decides whether to go to sleep according to all its
channels.

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
diff --git a/arch/arm/mach-msm/sdio_al.c b/arch/arm/mach-msm/sdio_al.c
index 981837c..9f845f2 100644
--- a/arch/arm/mach-msm/sdio_al.c
+++ b/arch/arm/mach-msm/sdio_al.c
@@ -254,9 +254,6 @@
 
 /* Allow support in old sdio version */
 #define PEER_SDIOC_OLD_VERSION_MAJOR	0x0002
-
-#define MAX_NUM_OF_SDIO_DEVICES		2
-
 #define INVALID_SDIO_CHAN		0xFF
 
 /**
@@ -611,6 +608,11 @@
 {
 	pr_debug(MODULE_NAME ": %s()", __func__);
 
+	if (!sdio_al_dev) {
+		pr_err(MODULE_NAME ": %s - sdio_al_dev is NULL\n", __func__);
+		return;
+	}
+
 	if (is_vote_for_sleep) {
 		LPM_DEBUG(MODULE_NAME ": %s - sdio vote for Sleep", __func__);
 		wake_unlock(&sdio_al_dev->wake_lock);
@@ -2033,7 +2035,6 @@
 	}
 
 	/* Wake up sequence */
-	sdio_al_vote_for_sleep(sdio_al_dev, 0);
 	if (not_from_int) {
 		LPM_DEBUG(MODULE_NAME ": Wake up card %d (not by interrupt)",
 			sdio_al_dev->card->host->index);
@@ -2048,6 +2049,7 @@
 			sdio_al_dev->card->host->index);
 		return 0;
 	}
+	sdio_al_vote_for_sleep(sdio_al_dev, 0);
 
 	pr_debug(MODULE_NAME ":Turn clock on for card %d\n",
 		 sdio_al_dev->card->host->index);
@@ -2062,6 +2064,7 @@
 			break;
 		udelay(TIME_TO_WAIT_US);
 	}
+
 	LPM_DEBUG(MODULE_NAME ":GPIO mdm2ap_status=%d\n",
 		       sdio_al->pdata->get_mdm2ap_status());