Merge "Revert "msm8960: mmc: Add power on write protection.""
diff --git a/platform/msm8960/platform.c b/platform/msm8960/platform.c
index 61c0ec4..d45b699 100644
--- a/platform/msm8960/platform.c
+++ b/platform/msm8960/platform.c
@@ -36,7 +36,6 @@
 #include <dev/fbcon.h>
 #include <mmu.h>
 #include <arch/arm/mmu.h>
-#include <partition_parser.h>
 
 extern void platform_init_timer(void);
 extern void platform_panel_backlight_on(void);
@@ -119,31 +118,12 @@
 		mipi_dsi_shutdown();
 }
 
-/*
- * Write-protect partition list.
- *
- * Partition added in this list should have (size + padding) in multiple of
- * mmc write protect group size. Otherwise this can end up write protecting
- * some blocks from next partition.
- */
-char *wp_list[] = {"fsg", NULL};
-
-void platform_wp_paritition(void)
-{
-	int count = 0;
-	while(wp_list[count] != NULL)
-	{
-		paritition_wp_by_name(wp_list[count]);
-		count++;
-	}
-}
-
 void platform_uninit(void)
 {
 #if DISPLAY_SPLASH_SCREEN
 	display_shutdown();
 #endif
-	platform_wp_paritition();
+
 	platform_uninit_timer();
 }
 
@@ -186,4 +166,3 @@
 {
 	return ticks_per_sec;
 }
-
diff --git a/platform/msm_shared/include/mmc.h b/platform/msm_shared/include/mmc.h
index 6c754ff..a07d169 100644
--- a/platform/msm_shared/include/mmc.h
+++ b/platform/msm_shared/include/mmc.h
@@ -374,7 +374,6 @@
 #define MMC_BOOT_E_DATA_ADM_ERR           21
 
 /* EXT_CSD */
-#define MMC_BOOT_ACCESS_BIT_SET           0x1
 #define MMC_BOOT_ACCESS_WRITE             0x3
 
 #define MMC_BOOT_EXT_USER_WP              171
@@ -594,10 +593,6 @@
 unsigned int mmc_erase_card(unsigned long long data_addr,
 			    unsigned long long data_len);
 
-unsigned int mmc_wp(unsigned int sector, unsigned int size,
-				unsigned char set_clear_wp);
-
 struct mmc_boot_host *get_mmc_host(void);
 struct mmc_boot_card *get_mmc_card(void);
-
 #endif
diff --git a/platform/msm_shared/include/partition_parser.h b/platform/msm_shared/include/partition_parser.h
index 48fd982..8e0f2ee 100644
--- a/platform/msm_shared/include/partition_parser.h
+++ b/platform/msm_shared/include/partition_parser.h
@@ -176,7 +176,6 @@
 		       struct mmc_boot_host *mmc_host,
 		       struct mmc_boot_card *mmc_card);
 unsigned int write_partition(unsigned size, unsigned char *partition);
-unsigned int paritition_wp_by_name(const char *name);
 
 /* For Debugging */
 void partition_dump(void);
diff --git a/platform/msm_shared/mmc.c b/platform/msm_shared/mmc.c
index 2d86ba1..b1fc977 100644
--- a/platform/msm_shared/mmc.c
+++ b/platform/msm_shared/mmc.c
@@ -85,6 +85,8 @@
 struct mmc_boot_host mmc_host;
 struct mmc_boot_card mmc_card;
 
+static unsigned int mmc_wp(unsigned int addr, unsigned int size,
+			   unsigned char set_clear_wp);
 static unsigned int mmc_boot_send_ext_cmd(struct mmc_boot_card *card,
 					  unsigned char *buf);
 static unsigned int mmc_boot_read_reg(struct mmc_boot_card *card,
@@ -2282,7 +2284,7 @@
 	       sizeof(struct mmc_boot_command));
 
 	/* Disabling PERM_WP for USER AREA (CMD6) */
-	mmc_ret = mmc_boot_switch_cmd(card, MMC_BOOT_ACCESS_BIT_SET,
+	mmc_ret = mmc_boot_switch_cmd(card, MMC_BOOT_ACCESS_WRITE,
 				      MMC_BOOT_EXT_USER_WP,
 				      MMC_BOOT_US_PERM_WP_DIS);
 
@@ -2336,14 +2338,14 @@
 		    (card->csd.erase_grp_mult + 1) * (card->csd.wp_grp_size +
 						      1);
 	}
-	dprintf(SPEW, "Write protect size: %d bytes\n", (wp_group_size * MMC_BOOT_WR_BLOCK_LEN));
+
 	if (wp_group_size == 0) {
 		return MMC_BOOT_E_FAILURE;
 	}
 
 	/* Setting POWER_ON_WP for USER AREA (CMD6) */
 
-	mmc_ret = mmc_boot_switch_cmd(card, MMC_BOOT_ACCESS_BIT_SET,
+	mmc_ret = mmc_boot_switch_cmd(card, MMC_BOOT_ACCESS_WRITE,
 				      MMC_BOOT_EXT_USER_WP,
 				      MMC_BOOT_US_PWR_WP_EN);
 
@@ -2371,9 +2373,6 @@
 
 	if (size % wp_group_size) {
 		loop_count = (size / wp_group_size) + 1;
-		dprintf(CRITICAL, "WARNING: Size passed to write protect is not multiple of wp_group_size!\n");
-		dprintf(CRITICAL, "WARNING: Write protecting %d extra bytes.\n",
-						((loop_count * wp_group_size) - size) * MMC_BOOT_WR_BLOCK_LEN);
 	} else {
 		loop_count = (size / wp_group_size);
 	}
@@ -2434,9 +2433,9 @@
 }
 
 /*
- * Function for setting Write protect for given sector
+ * Test Function for setting Write protect for given sector
  */
-unsigned int
+static unsigned int
 mmc_wp(unsigned int sector, unsigned int size, unsigned char set_clear_wp)
 {
 	unsigned int rc = MMC_BOOT_E_SUCCESS;
diff --git a/platform/msm_shared/partition_parser.c b/platform/msm_shared/partition_parser.c
index 2becaed..45f5413 100644
--- a/platform/msm_shared/partition_parser.c
+++ b/platform/msm_shared/partition_parser.c
@@ -946,42 +946,3 @@
 
 	return 0;
 }
-
-/*
- * Power on write protect partition by name.
- *
- * Partition passed to this function should have (size + padding) in multiple
- * of mmc write protect group size. Otherwise this can end up write protecting
- * some blocks from next partition.
- */
-
-unsigned int paritition_wp_by_name(const char *name)
-{
-	unsigned long long ptn = 0;
-	unsigned long long size = 0;
-	int index = INVALID_PTN;
-	unsigned int ret = MMC_BOOT_E_SUCCESS;
-
-	index = partition_get_index(name);
-	ptn = partition_get_offset(index);
-	if(ptn == 0) {
-		dprintf(CRITICAL, "%s partition not found.\n", name);
-		return 1;
-	}
-
-	size = partition_get_size(index);
-
-	/* Offset in sectors */
-	ptn = ptn / MMC_BOOT_RD_BLOCK_LEN;
-
-	/* Size in sectors */
-	size = size / MMC_BOOT_RD_BLOCK_LEN;
-
-	ret = mmc_wp((unsigned)ptn, (unsigned)size, 1);
-	if(ret)
-	{
-		dprintf(CRITICAL, "Failed to write protect: %s\n", name);
-		return 1;
-	}
-	return 0;
-}