Commit 8c11e41c authored by Bastien Nocera's avatar Bastien Nocera

linux: Allow batteries to report 0 as power_now

Which can happen for dual battery machines.

Closes: #44
parent 310a23eb
......@@ -674,8 +674,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
}
/* this is the new value in uW */
energy_rate = fabs (sysfs_get_double (native_path, "power_now") / 1000000.0);
if (energy_rate < 0.01) {
if (!sysfs_get_double_with_error (native_path, "power_now", &energy_rate)) {
gdouble charge_full;
/* convert charge to energy */
......@@ -696,6 +695,8 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
energy_rate = fabs (sysfs_get_double (native_path, "current_now") / 1000000.0);
if (charge_full != 0)
energy_rate *= voltage_design;
} else {
energy_rate = fabs (energy_rate / 1000000.0);
}
/* some batteries don't update last_full attribute */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment