Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 367468
b: refs/heads/master
c: 908fe8d
h: refs/heads/master
v: v3
  • Loading branch information
Hakan Berg authored and Lee Jones committed Mar 7, 2013
1 parent 517af80 commit bbda1bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d4f510f6c3f579bac0dbeaa8dc7c2dc768c31786
refs/heads/master: 908fe8d6a575e2bdf349ba8635b862eeb91f7ade
27 changes: 21 additions & 6 deletions trunk/drivers/power/ab8500_btemp.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ struct ab8500_btemp_ranges {
* @dev: Pointer to the structure device
* @node: List of AB8500 BTEMPs, hence prepared for reentrance
* @curr_source: What current source we use, in uA
* @bat_temp: Battery temperature in degree Celcius
* @prev_bat_temp Last dispatched battery temperature
* @bat_temp: Dispatched battery temperature in degree Celcius
* @prev_bat_temp Last measured battery temperature in degree Celcius
* @parent: Pointer to the struct ab8500
* @gpadc: Pointer to the struct gpadc
* @fg: Pointer to the struct fg
Expand Down Expand Up @@ -604,6 +604,7 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
static void ab8500_btemp_periodic_work(struct work_struct *work)
{
int interval;
int bat_temp;
struct ab8500_btemp *di = container_of(work,
struct ab8500_btemp, btemp_periodic_work.work);

Expand All @@ -614,12 +615,26 @@ static void ab8500_btemp_periodic_work(struct work_struct *work)
dev_warn(di->dev, "failed to identify the battery\n");
}

di->bat_temp = ab8500_btemp_measure_temp(di);

if (di->bat_temp != di->prev_bat_temp) {
di->prev_bat_temp = di->bat_temp;
bat_temp = ab8500_btemp_measure_temp(di);
/*
* Filter battery temperature.
* Allow direct updates on temperature only if two samples result in
* same temperature. Else only allow 1 degree change from previous
* reported value in the direction of the new measurement.
*/
if (bat_temp == di->prev_bat_temp || !di->initialized) {
if (di->bat_temp != di->prev_bat_temp || !di->initialized) {
di->bat_temp = bat_temp;
power_supply_changed(&di->btemp_psy);
}
} else if (bat_temp < di->prev_bat_temp) {
di->bat_temp--;
power_supply_changed(&di->btemp_psy);
} else if (bat_temp > di->prev_bat_temp) {
di->bat_temp++;
power_supply_changed(&di->btemp_psy);
}
di->prev_bat_temp = bat_temp;

if (di->events.ac_conn || di->events.usb_conn)
interval = di->bm->temp_interval_chg;
Expand Down

0 comments on commit bbda1bb

Please sign in to comment.