board: msm7x27a: Fix the battery capacity calculation logic.

Battery capacity calculation is missing boundary checks. This
is causing capacity to be more than 100%, when battery voltage
goes below minimum operating voltage. This inturn is causing
failure to trigger graceful shutdown at low voltages. Fix is
to have the boundary checks in capacity calculation.

CRs-Fixed: 369687
Change-Id: I25e9a09d4d9d0cb03ee38f589d20e5f807e801c9
Signed-off-by: Krishna Vanka <kvanka@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-msm7x27a.c b/arch/arm/mach-msm/board-msm7x27a.c
index 1c32b5e..1521a6c 100644
--- a/arch/arm/mach-msm/board-msm7x27a.c
+++ b/arch/arm/mach-msm/board-msm7x27a.c
@@ -650,7 +650,12 @@
 	u32 low_voltage	 = msm_psy_batt_data.voltage_min_design;
 	u32 high_voltage = msm_psy_batt_data.voltage_max_design;
 
-	return (current_voltage - low_voltage) * 100
+	if (current_voltage <= low_voltage)
+		return 0;
+	else if (current_voltage >= high_voltage)
+		return 100;
+	else
+		return (current_voltage - low_voltage) * 100
 			/ (high_voltage - low_voltage);
 }