summaryrefslogtreecommitdiff
path: root/src/linux/up-device-supply.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/linux/up-device-supply.c')
-rw-r--r--src/linux/up-device-supply.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index fd509c3..977d1b0 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -677,6 +677,10 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
/* get a precise percentage */
if (sysfs_file_exists (native_path, "capacity")) {
percentage = sysfs_get_double (native_path, "capacity");
+ if (percentage < 0.0f)
+ percentage = 0.0f;
+ if (percentage > 100.0f)
+ percentage = 100.0f;
/* for devices which provide capacity, but not {energy,charge}_now */
if (energy < 0.1f && energy_full > 0.0f)
energy = energy_full * percentage / 100;