In this patch calculate_charge_cycles function is cleaned. Mainly replaced msic_read_coloumb_ctr/cc_to_coloumbs with msic_get_charge_now And removed some unnecessary variables from the function. Also changed the global variable from chr_clmb_ctr to chr_clmb_cnt
Signed-off-by: Ramakrishna Pallala <[email protected]> --- drivers/power/intel_mdf_battery.c | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/power/intel_mdf_battery.c b/drivers/power/intel_mdf_battery.c index baa1917..431d190 100644 --- a/drivers/power/intel_mdf_battery.c +++ b/drivers/power/intel_mdf_battery.c @@ -305,7 +305,7 @@ static struct device *msic_dev; /* Variables for counting charge cycles */ static unsigned int charge_cycle_ctr; -static unsigned int chr_clmb_ctr; +static unsigned int chr_clmb_cnt; /* @@ -1683,23 +1683,21 @@ static void calculate_charge_cycles(struct msic_power_module_info *mbi, bool start_bit) { static unsigned int chr_prev; - unsigned int chr_now, chr_now_ctr, chr_prev_ctr = 0; + unsigned int chr_now; if (start_bit) chr_prev = 0; - chr_now = msic_read_coloumb_ctr(); - chr_now_ctr = cc_to_coloumbs(chr_now); - - chr_prev_ctr = cc_to_coloumbs(chr_prev); + chr_now = msic_get_charge_now(); /* count inflow charge given by charger */ if (!chr_prev) - chr_clmb_ctr += chr_now_ctr - chr_prev_ctr; + chr_clmb_cnt += chr_now - chr_prev; - if (chr_clmb_ctr >= CHARGE_FULL_IN_MAH) { + if (chr_clmb_cnt >= CHARGE_FULL_IN_MAH) { charge_cycle_ctr++; - chr_clmb_ctr = 0; + chr_clmb_cnt = 0; + dev_dbg(msic_dev, "charge cycle count:%d\n", charge_cycle_ctr); } chr_prev = chr_now; } @@ -2607,7 +2605,7 @@ static void do_exit_ops(struct msic_power_module_info *mbi) mutex_unlock(&mbi->batt_lock); /* Check charge Cycles */ - if (chr_clmb_ctr >= (CHARGE_FULL_IN_MAH / 2)) + if (chr_clmb_cnt >= (CHARGE_FULL_IN_MAH / 2)) charge_cycle_ctr++; } -- 1.7.2.3
0005-Cleaned-Charge-cycles-counting-function.patch
Description: 0005-Cleaned-Charge-cycles-counting-function.patch
_______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
