diff options
author | Lin Fuzhen <fuzhen.lin@freescale.com> | 2012-07-10 09:57:53 +0800 |
---|---|---|
committer | Lin Fuzhen <fuzhen.lin@freescale.com> | 2012-07-10 11:33:10 +0800 |
commit | 69e46757d03b2d34911a7ecd043dbcf47c5a8d09 (patch) | |
tree | cac1b486f08636d4d9056b110ff4ffe75a821026 /drivers/power | |
parent | 322208e066c37c65f60a74844e5851a2db86696a (diff) |
ENGR00216254 mx6 sabresd battery:change battery status update strategy
update the battery info just when the value is changed.
Signed-off-by: Lin Fuzhen <fuzhen.lin@freescale.com>
Diffstat (limited to 'drivers/power')
-rwxr-xr-x | drivers/power/sabresd_battery.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/power/sabresd_battery.c b/drivers/power/sabresd_battery.c index 460da4a43b72..94d7e4194f96 100755 --- a/drivers/power/sabresd_battery.c +++ b/drivers/power/sabresd_battery.c @@ -65,7 +65,6 @@ typedef struct { u32 percent; } battery_capacity , *pbattery_capacity; -static bool capacity_changed_flag; static int cpu_type_flag; static int offset_discharger; static int offset_charger; @@ -248,9 +247,10 @@ u32 calibration_voltage(struct max8903_data *data) static void max8903_battery_update_status(struct max8903_data *data) { - static int counter; int temp; static int temp_last; + bool changed_flag; + changed_flag = false; mutex_lock(&data->work_lock); temp = calibration_voltage(data); if (temp_last == 0) { @@ -272,17 +272,13 @@ static void max8903_battery_update_status(struct max8903_data *data) data->percent = calibrate_battery_capability_percent(data); if (data->percent != data->old_percent) { data->old_percent = data->percent; - capacity_changed_flag = true; + changed_flag = true; } - if ((capacity_changed_flag == true)) { - counter++; - if (counter > 2) { - counter = 0; - capacity_changed_flag = false; - power_supply_changed(&data->bat); - } + if (changed_flag) { + changed_flag = false; + power_supply_changed(&data->bat); } - power_supply_changed(&data->bat); + mutex_unlock(&data->work_lock); } @@ -560,7 +556,6 @@ static __devinit int max8903_probe(struct platform_device *pdev) data->pdata = pdata; data->dev = dev; platform_set_drvdata(pdev, data); - capacity_changed_flag = false; data->usb_in = 0; data->ta_in = 0; if (pdata->dc_valid == false && pdata->usb_valid == false) { |