Battery: prevent division by zero
This commit is contained in:
parent
b887d50409
commit
42d1ba2b20
1 changed files with 1 additions and 1 deletions
|
@ -286,7 +286,7 @@ static gint estimate_power_usage(struct psy_battery *bat, gint old_energy_now, g
|
|||
gint64 diff_time = bat->timestamp - old_timestamp;
|
||||
|
||||
/* µW = (µWh * 3600) / (µs * 1000000) */
|
||||
gint power = diff_power * 3600 * 1000000 / diff_time;
|
||||
gint power = diff_power * 3600 * 1000000 / MAX(1, diff_time);
|
||||
|
||||
return power;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue