hal/hald/linux2 acpi.c,1.31,1.32
Danny Kukawka
dkukawka at freedesktop.org
Thu Aug 11 11:54:41 PDT 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv17588/hald/linux2
Modified Files:
acpi.c
Log Message:
2005-08-11 Danny Kukawka <danny.kukawka at web.de>
* hald/linux2/acpi.c: (battery_refresh_poll): Fixed several battery keys
to be sure that hal not provides battery key with not up-to-date values,
if the battery is full charged. Now we set all values which are in
/proc/acpi/battery/*/{info,state} already 'unknown' (e.g. 'present rate')
to 0.
Index: acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/acpi.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- acpi.c 11 Aug 2005 07:10:10 -0000 1.31
+++ acpi.c 11 Aug 2005 18:54:39 -0000 1.32
@@ -95,10 +95,12 @@
* we'll use the .reporting prefix as we don't know
* if this data is energy (mWh) or unit enery (mAh)
*/
- hal_util_set_int_elem_from_file (d, "battery.reporting.current", path,
- "state", "remaining capacity", 0, 10, TRUE);
- hal_util_set_int_elem_from_file (d, "battery.reporting.rate", path,
- "state", "present rate", 0, 10, TRUE);
+ if (!hal_util_set_int_elem_from_file (d, "battery.reporting.current", path,
+ "state", "remaining capacity", 0, 10, TRUE))
+ hal_device_property_set_int (d, "battery.reporting.current", 0);
+ if (!hal_util_set_int_elem_from_file (d, "battery.reporting.rate", path,
+ "state", "present rate", 0, 10, TRUE))
+ hal_device_property_set_int (d, "battery.reporting.rate", 0);
/*
* we'll need this if we need to convert mAh to mWh, but we should
* also update it here anyway as the value will have changed
@@ -145,25 +147,33 @@
mwh_rate = 0;
}
- /*
- * Set these new mWh only keys. Only add valid keys!
- */
- if (mwh_current >= 0)
- hal_device_property_set_int (d, "battery.charge_level.current", mwh_current);
- if (mwh_lastfull >= 0)
- hal_device_property_set_int (d, "battery.charge_level.last_full", mwh_lastfull);
- if (mwh_rate >= 0)
- hal_device_property_set_int (d, "battery.charge_level.rate", mwh_rate);
-
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);
- if (remaining_time >= 0)
- hal_device_property_set_int (d, "battery.remaining_time", remaining_time);
- if (remaining_percentage >= 0)
- hal_device_property_set_int (d, "battery.charge_level.percentage", remaining_percentage);
+ /*
+ * Only add valid keys!
+ */
+ if (remaining_time < 0)
+ remaining_time = 0;
+ if (remaining_percentage < 0)
+ remaining_percentage = 0;
+ /*
+ * Set these new mWh only keys.
+ */
+ if (mwh_current < 0)
+ mwh_current = 0;
+ if (mwh_lastfull < 0)
+ mwh_lastfull = 0;
+ if (mwh_rate < 0)
+ mwh_rate = 0;
+
+ 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);
out:
;
More information about the hal-commit
mailing list