mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-13 16:16:15 -04:00
need to clear jiffies in non-charging state.
The jiffies value is only recorded in the charging state, and it needs to be cleared in other states. Change-Id: I9beb3465a24784d35399c10733416f3104269678 Reviewed-on: https://gerrit.mot.com/2601217 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Wentao Xu <xuwt2@motorola.com> Reviewed-by: Guobin Zhang <zhanggb@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
d73cc9a3e8
commit
89cb6ae120
1 changed files with 12 additions and 10 deletions
|
|
@ -342,22 +342,23 @@ static int cw_get_voltage(struct cw_battery *cw_bat)
|
|||
#define MAX_VAL( x, y ) ( ((x) > (y)) ? (x) : (y) )
|
||||
#endif
|
||||
#define TIMER_INTERVALS 1000 * 60 /* unit:ms */
|
||||
static bool jiffies_timer_expire(void) {
|
||||
static bool jiffies_timer_expire(bool clear_flag) {
|
||||
unsigned long cur_jiffies = jiffies;
|
||||
static unsigned long last_jiffies = 0;
|
||||
unsigned long intr_timeout = msecs_to_jiffies(TIMER_INTERVALS);
|
||||
bool ret = false;
|
||||
|
||||
if (!last_jiffies)
|
||||
if (!last_jiffies || clear_flag) {
|
||||
last_jiffies = cur_jiffies;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (time_after(cur_jiffies, intr_timeout + last_jiffies))
|
||||
if (time_after(cur_jiffies, msecs_to_jiffies(TIMER_INTERVALS) + last_jiffies))
|
||||
ret = true;
|
||||
else
|
||||
ret = false;
|
||||
|
||||
if (ret) {
|
||||
cw_printk("expire 60s, curr_jiffies:%dms, last jiffies %d",
|
||||
cw_printk("expire 60s, curr_jiffies:%dms, last jiffies %d",
|
||||
jiffies_to_msecs(cur_jiffies), jiffies_to_msecs(last_jiffies));
|
||||
last_jiffies = cur_jiffies;
|
||||
|
||||
|
|
@ -400,20 +401,20 @@ static int cw_get_capacity(struct cw_battery *cw_bat)
|
|||
|
||||
if (chr_st_now) {
|
||||
if (ui_full_temp > cw_bat->ui_full) {
|
||||
if (jiffies_timer_expire() &&
|
||||
(cw_bat->batt_status == POWER_SUPPLY_STATUS_CHARGING)) {
|
||||
if (jiffies_timer_expire(false)) {
|
||||
ui_full_temp -= 1;
|
||||
cw_printk("CW2015[%d]: UI_FULL-- %d!!!!\n", __LINE__, ui_full_temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!chr_st_now) {
|
||||
if (!chr_st_now) {
|
||||
if ((soc_h * 256 + soc_l) / 256 > ui_full_temp) {
|
||||
cw_printk("CW2015[%d]: update UI_FULL to %d from %d !!!!\n", __LINE__, (soc_h * 256 + soc_l) / 256, ui_full_temp);
|
||||
ui_full_temp = (soc_h * 256 + soc_l) / 256;
|
||||
}
|
||||
}
|
||||
jiffies_timer_expire(true);
|
||||
}
|
||||
|
||||
ui_full_pre = ui_full_temp;
|
||||
ui_soc = ((soc_h * 256 + soc_l) * 100)/ (ui_full_pre * 256);
|
||||
|
|
@ -430,7 +431,8 @@ static int cw_get_capacity(struct cw_battery *cw_bat)
|
|||
}
|
||||
|
||||
if (cw_bat->ui_soc != ui_soc) {
|
||||
cw_printk("CW2015[%d]: not update, cw_bat->ui_soc %d, ui_soc %d", __LINE__, cw_bat->ui_soc, ui_soc);
|
||||
cw_printk("CW2015[%d]: not update, cw_bat->ui_soc %d, ui_soc %d, chrg_st_now %d",
|
||||
__LINE__, cw_bat->ui_soc, ui_soc, chr_st_now);
|
||||
}
|
||||
|
||||
cw_bat->ic_soc_h = soc_h;
|
||||
|
|
|
|||
Loading…
Reference in a new issue