aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorOleksandr Kozaruk <oleksandr.kozaruk@ti.com>2012-02-03 19:18:49 -0600
committerZiyann <jaraidaniel@gmail.com>2014-10-01 13:00:24 +0200
commit9dba284e7e22705ca9e4c1b53fc8a49c8dcec970 (patch)
tree33e2461651a0919aeb4c1337b0a923f571e5b3a7 /drivers/power
parent93f87087fa4b6a0481af4c2378efaded0a77c8dc (diff)
downloadkernel_samsung_tuna-9dba284e7e22705ca9e4c1b53fc8a49c8dcec970.zip
kernel_samsung_tuna-9dba284e7e22705ca9e4c1b53fc8a49c8dcec970.tar.gz
kernel_samsung_tuna-9dba284e7e22705ca9e4c1b53fc8a49c8dcec970.tar.bz2
OMAP4: battery: Capacity debounce.
Counter was used for capacity debounce, that counted how many times capacity was different from currently reported to the kernel. Make debounce procedure more aggressive, count how many times capacity stays the _same_ after it changed, not just different. If it is the same after N times, update it. Change-Id: Iece0f9afe58007c14ad787051280f8ba0337f3bb Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/twl6030_bci_battery.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/power/twl6030_bci_battery.c b/drivers/power/twl6030_bci_battery.c
index 0c6178a..6d596fc 100644
--- a/drivers/power/twl6030_bci_battery.c
+++ b/drivers/power/twl6030_bci_battery.c
@@ -294,6 +294,7 @@ struct twl6030_bci_device_info {
unsigned int capacity;
unsigned int capacity_debounce_count;
unsigned long ac_next_refresh;
+ unsigned int prev_capacity;
unsigned int wakelock_enabled;
struct power_supply bat;
@@ -1587,22 +1588,23 @@ static int capacity_changed(struct twl6030_bci_device_info *di)
if (!is_battery_present(di))
curr_capacity = 100;
- /* Debouncing of voltage change. */
- if (curr_capacity != di->capacity)
- di->capacity_debounce_count++;
- else
+ /* Debouncing of voltage change. */
+ if (di->capacity == -1) {
+ di->capacity = curr_capacity;
di->capacity_debounce_count = 0;
+ return 1;
+ }
- if ((di->capacity_debounce_count >= 4)
- || (di->capacity == -1)) {
+ if (curr_capacity != di->prev_capacity) {
+ di->prev_capacity = curr_capacity;
+ di->capacity_debounce_count = 0;
+ } else if (++di->capacity_debounce_count >= 4) {
di->capacity = curr_capacity;
di->capacity_debounce_count = 0;
return 1;
}
-
return 0;
-
}
static int twl6030_set_watchdog(struct twl6030_bci_device_info *di, int val)