Issue: "POWER_SUPPLY_CHARGE_NOW is greater than POWER_SUPPLY_CHARGE_FULL" (Bug 7312).
Update coulomb counter value when user space application writes battery_capacity_percent.
Do not need to keep updating coulomb counter value for SCU will maintain it.
This patch also fix a memory leak problem.

Signed-off-by: Major Lee <major_lee@wistron.com>
---

--- linux-2.6.37.bak/drivers/power/intel_pmic_battery.c	2011-06-07 17:03:15.169862268 +0800
+++ linux-2.6.37/drivers/power/intel_pmic_battery.c	2011-06-08 11:51:30.763381000 +0800
@@ -1078,13 +1078,22 @@ battery_capacity_percent_store(struct ko
 					const char *buf, size_t n)
 {
 	unsigned long percent = simple_strtoul(buf, NULL, 0x10);
+	struct battery_property batt_prop;
+	u32 write_ccval;
 
 	if (percent > 100)
 		batt_capacity_percent = 100;
 	else
 		batt_capacity_percent = percent;
+
+	if (!batt_capacity_flag) {
+		/* Update coulomb counter value */
+		if (!pmic_scu_ipc_battery_property_get(&batt_prop)) {
+			write_ccval = batt_prop.capacity * batt_capacity_percent / 100;
+			pmic_scu_ipc_battery_cc_write(&write_ccval);
+		}
+	}
 	batt_capacity_flag = true;
-	/* FIXME: consistent kobject and struct pmic_power_info by container_of() */
 
 	return n;
 }
@@ -1199,7 +1208,7 @@ mid_battery_read(struct file * file, cha
 	len = count / sizeof(struct battery_info);
 	kbuf = kmalloc(sizeof(struct battery_info) * len, GFP_KERNEL);
 	if (!kbuf) {
-		retval = -EFAULT;
+		retval = -ENOMEM;
 		goto read_fail;
 	}
 
@@ -1217,6 +1226,7 @@ mid_battery_read(struct file * file, cha
 	if (copy_to_user(buf, kbuf, sizeof(struct battery_info) * len) == 0)
 		retval = sizeof(struct battery_info) * len;
 
+	kfree(kbuf);
 read_fail:
 	return retval;
 }
