hal/hald/linux2 acpi.c,1.33,1.34
Richard Hughes
hughsient at freedesktop.org
Fri Aug 19 12:32:43 PDT 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv18432
Modified Files:
acpi.c
Log Message:
Remove checks for negative times and percentages.
Index: acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/acpi.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- acpi.c 11 Aug 2005 21:19:57 -0000 1.33
+++ acpi.c 19 Aug 2005 19:32:41 -0000 1.34
@@ -146,18 +146,6 @@
mwh_rate = 0;
}
- remaining_time = util_compute_time_remaining ( d->udi, mwh_rate, mwh_current, mwh_lastfull,
- hal_device_property_get_bool (d, "battery.rechargeable.is_discharging"),
- hal_device_property_get_bool (d, "battery.rechargeable.is_charging"));
- remaining_percentage = util_compute_percentage_charge ( d->udi, mwh_current, mwh_lastfull);
-
- /*
- * Only add valid keys!
- */
- if (remaining_time < 0)
- remaining_time = 0;
- if (remaining_percentage < 0)
- remaining_percentage = 0;
/*
* Set these new mWh only keys.
*/
@@ -171,8 +159,25 @@
hal_device_property_set_int (d, "battery.charge_level.current", mwh_current);
hal_device_property_set_int (d, "battery.charge_level.last_full", mwh_lastfull);
hal_device_property_set_int (d, "battery.charge_level.rate", mwh_rate);
- hal_device_property_set_int (d, "battery.remaining_time", remaining_time);
- hal_device_property_set_int (d, "battery.charge_level.percentage", remaining_percentage);
+
+ remaining_time = util_compute_time_remaining (d->udi, mwh_rate, mwh_current, mwh_lastfull,
+ hal_device_property_get_bool (d, "battery.rechargeable.is_discharging"),
+ hal_device_property_get_bool (d, "battery.rechargeable.is_charging"));
+ remaining_percentage = util_compute_percentage_charge (d->udi, mwh_current, mwh_lastfull);
+ /*
+ * Only set keys if no error (signified with negative return value)
+ * Scrict checking is needed to ensure that the values presented by HAL
+ * are 100% acurate.
+ */
+ if (remaining_time > 0)
+ hal_device_property_set_int (d, "battery.remaining_time", remaining_time);
+ else
+ hal_device_property_remove (d, "battery.remaining_time");
+
+ if (remaining_percentage > 0)
+ hal_device_property_set_int (d, "battery.charge_level.percentage", remaining_percentage);
+ else
+ hal_device_property_remove (d, "battery.charge_level.percentage");
out:
;
More information about the hal-commit
mailing list