hal: Branch 'master'
Danny Kukawka
dkukawka at kemper.freedesktop.org
Tue Jan 29 11:39:18 PST 2008
hald/linux/device.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
New commits:
commit 7e221dfb85e7be5ed3eb447c5051823f0d5519a3
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Tue Jan 29 20:38:42 2008 +0100
power_supply battery: moved static stuff to refresh_battery_slow()
Moved static info (*_design) from refresh_battery_fast() to
refresh_battery_slow() since they should never change after the first
read of them. Try to set also battery.reporting.unit directly to
prevent reread in refresh_battery_fast().
diff --git a/hald/linux/device.c b/hald/linux/device.c
index b490b6f..f82585f 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -3006,12 +3006,10 @@ refresh_battery_fast (HalDevice *d)
{
gint percentage = 0;
gint voltage_now = 0;
- gint voltage_design = 0;
gint current = 0;
gint time = 0;
gint value_now = 0;
gint value_last_full = 0;
- gint value_full_design = 0;
gboolean present = FALSE;
gboolean unknown_unit = TRUE;
gboolean is_mah = FALSE;
@@ -3051,10 +3049,6 @@ refresh_battery_fast (HalDevice *d)
} else if (hal_util_get_int_from_file (path, "voltage_now", &voltage_now, 10)) {
hal_device_property_set_int (d, "battery.voltage.current", voltage_now / 1000);
}
- if (hal_util_get_int_from_file (path, "voltage_max_design", &voltage_design, 10)) {
- hal_device_property_set_int (d, "battery.voltage.design", voltage_design / 1000);
- hal_device_property_set_string (d, "battery.voltage.unit", "mV");
- }
/* CURRENT: we prefer the average if it exists, although present is still pretty good */
if (!hal_util_get_int_from_file (path, "current_avg", ¤t, 10)) {
@@ -3115,10 +3109,6 @@ refresh_battery_fast (HalDevice *d)
hal_device_property_set_int (d, "battery.reporting.last_full", value_last_full / 1000);
is_mwh = TRUE;
}
- if (hal_util_get_int_from_file (path, "energy_full_design", &value_full_design, 10)) {
- hal_device_property_set_int (d, "battery.reporting.design", value_full_design / 1000);
- is_mwh = TRUE;
- }
}
/* CHARGE (reported in uAh, so need to convert to mAh) */
@@ -3134,10 +3124,6 @@ refresh_battery_fast (HalDevice *d)
hal_device_property_set_int (d, "battery.reporting.last_full", value_last_full / 1000);
is_mah = TRUE;
}
- if (hal_util_get_int_from_file (path, "charge_full_design", &value_full_design, 10)) {
- hal_device_property_set_int (d, "battery.reporting.design", value_full_design / 1000);
- is_mah = TRUE;
- }
}
/* record these for future savings */
@@ -3176,6 +3162,8 @@ refresh_battery_fast (HalDevice *d)
static void
refresh_battery_slow (HalDevice *d)
{
+ gint voltage_design = 0;
+ gint value_full_design = 0;
char *technology_raw;
char *model_name;
char *manufacturer;
@@ -3207,6 +3195,21 @@ refresh_battery_slow (HalDevice *d)
hal_device_property_set_string (d, "battery.vendor", manufacturer);
}
+ /* get stuff that never changes */
+ if (hal_util_get_int_from_file (path, "voltage_max_design", &voltage_design, 10)) {
+ hal_device_property_set_int (d, "battery.voltage.design", voltage_design / 1000);
+ hal_device_property_set_string (d, "battery.voltage.unit", "mV");
+ }
+
+ /* try to get the design info and set the units */
+ if (hal_util_get_int_from_file (path, "energy_full_design", &value_full_design, 10)) {
+ hal_device_property_set_int (d, "battery.reporting.design", value_full_design / 1000);
+ hal_device_property_set_string (d, "battery.reporting.unit", "mWh");
+ } else if (hal_util_get_int_from_file (path, "charge_full_design", &value_full_design, 10)) {
+ hal_device_property_set_int (d, "battery.reporting.design", value_full_design / 1000);
+ hal_device_property_set_string (d, "battery.reporting.unit", "mAh");
+ }
+
/* now do stuff that happens quickly */
refresh_battery_fast (d);
}
More information about the hal-commit
mailing list