MMC hang during reboot from dequeue of mmc device

This commit resolves the issue where the Intel Edison
will hang if rebooted more than once (repeated reboots).
It was found that the mmc device was being registerd
twice with 2 shutdown functions. When a device
reboot/shutdown operation was called the same mmc device
was trying to be cancelled from a workqueue. This
situation caused a race condition on the second operation
since the cancelled work will wait for completion.

Also added in code needed for proper resume setting for MMC
power state.

Change-Id: I1400df84e178d2b582725db2129ea7ee7c28a4da
Signed-off-by: Brian Wood <brian.j.wood@intel.com>
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 7fedaa6..3ade58e 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -2576,24 +2576,10 @@
 {
 	struct mmc_blk_data *part_md;
 	struct mmc_blk_data *md = mmc_get_drvdata(card);
-
 	if (md) {
 		mmc_queue_suspend(&md->queue);
 		list_for_each_entry(part_md, &md->part, part) {
 			mmc_queue_suspend(&part_md->queue);
-			if (part_md->part_type ==
-				EXT_CSD_PART_CONFIG_ACC_RPMB) {
-				/*
-				 * RPMB partition is accessed by API directly.
-				 * Driver need to set a flag when suspending
-				 * MMC block device to notify API that the
-				 * accessing of RPMB partition needs to be
-				 * stopped
-				 */
-				mmc_claim_host(card->host);
-				part_md->flags |= MMC_BLK_SUSPENDED;
-				mmc_release_host(card->host);
-			}
 		}
 	}
 	return 0;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 98a7e48..4744f7c 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1582,14 +1582,6 @@
 }
 
 /*
- * Shutdown callback
- */
-static int mmc_shutdown(struct mmc_host *host)
-{
-	return _mmc_suspend(host, false);
-}
-
-/*
  * Resume callback from host.
  *
  * This function tries to determine if the same card is still present
@@ -1660,7 +1652,6 @@
 	.resume = NULL,
 	.power_restore = mmc_power_restore,
 	.alive = mmc_alive,
-	.shutdown = mmc_shutdown,
 };
 
 static const struct mmc_bus_ops mmc_ops_unsafe = {
@@ -1672,7 +1663,6 @@
 	.resume = mmc_resume,
 	.power_restore = mmc_power_restore,
 	.alive = mmc_alive,
-	.shutdown = mmc_shutdown,
 };
 
 static void mmc_attach_bus_ops(struct mmc_host *host)
diff --git a/drivers/staging/edison-bcm43340/bcmsdh_sdmmc_linux.c b/drivers/staging/edison-bcm43340/bcmsdh_sdmmc_linux.c
index 1d5e579..746a1a3 100644
--- a/drivers/staging/edison-bcm43340/bcmsdh_sdmmc_linux.c
+++ b/drivers/staging/edison-bcm43340/bcmsdh_sdmmc_linux.c
@@ -362,6 +362,8 @@
 #if defined(OOB_INTR_ONLY)
 	bcmsdh_resume(sdioh->bcmsdh);
 #endif 
+	if (func->card && func->card->host)
+		func->card->host->pm_flags &= ~MMC_PM_KEEP_POWER;
 
 	smp_mb();
 	return 0;